home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mnyth3 / manythng.frm < prev    next >
Text File  |  1995-05-02  |  101KB  |  4,110 lines

  1. VERSION 2.00
  2. Begin Form ManyThings 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   1845
  7.    ClientTop       =   1710
  8.    ClientWidth     =   7995
  9.    ControlBox      =   0   'False
  10.    Height          =   5010
  11.    Icon            =   MANYTHNG.FRX:0000
  12.    Left            =   1785
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   307
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   533
  17.    Top             =   1365
  18.    Width           =   8115
  19.    Begin Timer Tick 
  20.       Enabled         =   0   'False
  21.       Interval        =   50
  22.       Left            =   10
  23.       Top             =   10
  24.    End
  25.    Begin Label PasswordLabel 
  26.       Alignment       =   1  'Right Justify
  27.       BackColor       =   &H00FFFFFF&
  28.       BorderStyle     =   1  'Fixed Single
  29.       Caption         =   "Need Password    "
  30.       FontBold        =   -1  'True
  31.       FontItalic      =   0   'False
  32.       FontName        =   "MS Sans Serif"
  33.       FontSize        =   24
  34.       FontStrikethru  =   0   'False
  35.       FontUnderline   =   0   'False
  36.       Height          =   690
  37.       Left            =   2430
  38.       TabIndex        =   0
  39.       Top             =   3510
  40.       Visible         =   0   'False
  41.       Width           =   4470
  42.    End
  43. End
  44. ' BackGround -- this form expands to fill the whole
  45. '   screen and is used as the back drop for all the
  46. '   drawing
  47.  
  48. Option Explicit
  49.  
  50. ' variables declared here
  51. Dim MouseX, MouseY ' Last position of the mouse moves
  52. Dim LastX As Integer, LastY As Integer
  53. 'Dim conv2x As Single, conv2y As Single
  54. Dim LastTime As Long
  55. Dim CurrentTime As Long
  56. Dim LinkTime As Long
  57. Dim PlotType As Integer
  58. Dim PlotInit As Integer
  59. Dim PlotEnd As Integer
  60. Dim RepeatIndex As Integer
  61. Dim Pointer As Integer
  62. Dim Mirror As Integer
  63. Dim RunMode As Integer
  64. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  65. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  66. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  67. Dim l As Long
  68. Dim m As Long
  69. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  70. Dim TimeInterval As Long
  71. Dim MaxTime As Long
  72. Dim Repeats As Integer
  73. Dim i As Integer
  74. Dim BoxHeight As Integer, BoxWidth As Integer
  75. Dim DC As Integer
  76. Dim Pattern As Long, Locked As Integer
  77. Dim Direction As Integer
  78. Dim Number As Integer
  79. Dim PicWidth As Integer, PicHeight As Integer
  80. Dim PriorityBreakPoints() As Single
  81. Dim Priorities() As Integer
  82. Dim TotalPriority As Single
  83. Dim MaxPlotType As Integer
  84.  
  85. ' values for GetBrightNonGray:
  86. ' minimum magnitude squared of colors
  87. Const MinColor = 3000' was 10000
  88. ' minimum difference between colors
  89. Const MinDiff = 30
  90.  
  91. 'Allocate Memory
  92. Dim x1a() As Integer
  93. Dim x2a() As Integer
  94. Dim y1a() As Integer
  95. Dim y2a() As Integer
  96. Dim x1da() As Integer
  97. Dim x2da() As Integer
  98. Dim y1da() As Integer
  99. Dim y2da() As Integer
  100. Dim x1sa() As Single
  101. Dim x2sa() As Single
  102. Dim y1sa() As Single
  103. Dim y2sa() As Single
  104. Dim vx1sa() As Single
  105. Dim vx2sa() As Single
  106. Dim vy1sa() As Single
  107. Dim vy2sa() As Single
  108. Dim ax1sa() As Single
  109. Dim ax2sa() As Single
  110. Dim ay1sa() As Single
  111. Dim ay2sa() As Single
  112. Dim Colors() As Long
  113. Dim DataPts() As Integer
  114.  
  115. 'for filled polygons
  116. Dim Points() As POINTAPI
  117.  
  118. Const PI = 3.14159265358979
  119. Const Sin45 = .707106781186547
  120. Const Cos45 = Sin45
  121. Const Sin22_5 = .38268343236509
  122. Const Cos22_5 = .923879532511287
  123. Const Sin11_25 = .195090322016128
  124. Const Cos11_25 = .98078528040323
  125. Const HighMirror = 10
  126.  
  127. Function CheckIfValidSaver (NeedsMuchMemory As Integer) As Integer
  128.   'when in low memory mode the saver only runs the modules
  129.   'that draw on the screen, not those that manipulate
  130.   'bitmaps, savers that use more memory will pass
  131.   'NeedsMuchMemory as a non-zero value
  132.  
  133.   If LowMemoryFlag = 0 Then 'if not low memory mode then done
  134.     CheckIfValidSaver = 1
  135.   Else
  136.     If NeedsMuchMemory <> 0 Then
  137.       LogFile ("Saver not valid in low memory: " + Str$(PlotType)), 0
  138.       NextSelection
  139.       CheckIfValidSaver = 0
  140.     Else
  141.       CheckIfValidSaver = 1
  142.     End If
  143.  
  144.   End If
  145.  
  146.   If Priorities(PlotType) = 0 Then
  147.     LogFile ("Saver disabled: " + Str$(PlotType)), 0
  148.     NextSelection
  149.     CheckIfValidSaver = 0
  150.   End If
  151.  
  152. End Function
  153.  
  154. Sub Circles ()
  155.   
  156.   ' have a single elipse trace across the
  157.   ' screen with multiple previous copies following
  158.   ' it
  159.  
  160.   Dim xRadius As Integer, yRadius As Integer
  161.   Dim HighMirror As Integer
  162.  
  163.   ' if first time then initialize
  164.   If PlotInit = False Then
  165.  
  166.    'see if we need to reset changes made from previous init
  167.    If PlotEnd = False Then
  168.  
  169.     'check if saver is permitted to run
  170.     If CheckIfValidSaver(0) = 0 Then
  171.       Exit Sub
  172.     End If
  173.     
  174.     PlotInit = True
  175.     Cls
  176.     ForeColor = QBColor(15)
  177.  
  178.     'Set array size and clear the elements
  179.     ReDim x1a(MaxLines) As Integer
  180.     ReDim x2a(MaxLines) As Integer
  181.     ReDim y1a(MaxLines) As Integer
  182.     ReDim y2a(MaxLines) As Integer
  183.  
  184.     Pointer = 1     ' start with array element 1
  185.     
  186.     ' set index to count number of times to repeat color
  187.     '   to past maxvalue so that it will be recalculated
  188.     RepeatIndex = MaxLines + 1
  189.  
  190.     'determine initial position of line
  191.     x1 = Rnd * ScaleWidth
  192.     x2 = Rnd * ScaleWidth
  193.     y1 = Rnd * ScaleHeight
  194.     y2 = Rnd * ScaleHeight
  195.  
  196.     'set initial velocity
  197.     vx1 = 0
  198.     vx2 = 0
  199.     vy1 = 0
  200.     vy2 = 0
  201.  
  202.     'set initial acceleration
  203.     ax1 = 0
  204.     ax2 = 0
  205.     ay1 = 0
  206.     ay2 = 0
  207.     
  208.     'find background color
  209.     m = QBColor(0)
  210.  
  211.     'Calculate velocity limits
  212.     MaxSpeedX = ScaleWidth * 15! / 800
  213.     MaxSpeedY = ScaleWidth * 15! / 600
  214.  
  215.     'select mirroring method
  216.     HighMirror = 5
  217.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  218.  
  219.   Else 'reset changes done by previous init
  220.  
  221.     ClearScreen
  222.  
  223.     'zero array sizes
  224.     ReDim x1a(0) As Integer
  225.     ReDim x2a(0) As Integer
  226.     ReDim y1a(0) As Integer
  227.     ReDim y2a(0) As Integer
  228.  
  229.   End If
  230.  
  231.   Else  ' put run code here
  232.  
  233.     Tick.Enabled = False' disable timer until circles completed
  234.  
  235.     ' check if time to get a new color
  236.     If RepeatIndex > RepeatCount Then
  237.     
  238.     'set color
  239.     l = GetBrightNonGray()
  240.  
  241.     RepeatIndex = 1
  242.     Else
  243.     RepeatIndex = RepeatIndex + 1
  244.     End If
  245.  
  246.     'Delete original circle
  247.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  248.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  249.     If xRadius <> 0 Then
  250.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  251.     End If
  252.  
  253.     DoEvents
  254.  
  255.     Select Case Mirror
  256.     Case 1: 'mirror on x and y axis
  257.         
  258.         'Delete original circle mirrored on Y axis
  259.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  260.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  261.         If xRadius <> 0 Then
  262.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  263.         End If
  264.  
  265.         DoEvents
  266.  
  267.         'Delete original circle mirrored on X axis
  268.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  269.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  270.         If xRadius <> 0 Then
  271.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  272.         End If
  273.  
  274.         DoEvents
  275.  
  276.         'Delete original circle mirrored on origin
  277.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  278.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  279.         If xRadius <> 0 Then
  280.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  281.         End If
  282.  
  283.         DoEvents
  284.  
  285.     Case 2: 'mirror on Y axis
  286.         
  287.         'Delete original circle mirrored on Y axis
  288.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  289.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  290.         If xRadius <> 0 Then
  291.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  292.         End If
  293.  
  294.         DoEvents
  295.  
  296.     Case 3: 'mirror around center point
  297.     
  298.         'Delete original circle mirrored on origin
  299.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  300.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  301.         If xRadius <> 0 Then
  302.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  303.         End If
  304.  
  305.         DoEvents
  306.  
  307.     Case Else: ' otherwise ignore (i.e. no mirror)
  308.     
  309.     End Select
  310.  
  311.     'Save New Circle
  312.     x1a(Pointer) = x1
  313.     x2a(Pointer) = x2
  314.     y1a(Pointer) = y1
  315.     y2a(Pointer) = y2
  316.  
  317.     Select Case Mirror
  318.     Case 1: 'mirror on x and y axis
  319.         
  320.         'Delete original circle mirrored on Y axis
  321.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  322.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  323.         If xRadius <> 0 Then
  324.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  325.         End If
  326.  
  327.         DoEvents
  328.  
  329.         'Delete original circle mirrored on X axis
  330.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  331.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  332.         If xRadius <> 0 Then
  333.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  334.         End If
  335.  
  336.         DoEvents
  337.  
  338.         'Delete original circle mirrored on origin
  339.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  340.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  341.         If xRadius <> 0 Then
  342.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  343.         End If
  344.  
  345.     Case 2: 'mirror on Y axis
  346.         
  347.         'Delete original circle mirrored on y axis
  348.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  349.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  350.         If xRadius <> 0 Then
  351.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  352.         End If
  353.  
  354.     Case 3: 'mirror around center point
  355.     
  356.         'Delete original circle mirrored on origin
  357.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  358.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  359.         If xRadius <> 0 Then
  360.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  361.         End If
  362.  
  363.     Case Else: ' otherwise ignore (i.e. no mirror)
  364.     
  365.     End Select
  366.  
  367.     DoEvents
  368.  
  369.     Tick.Enabled = True' re-enable timer
  370.  
  371.     'Draw new Circle
  372.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  373.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  374.     If xRadius <> 0 Then
  375.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  376.     End If
  377.  
  378.     'Move pointer to next item
  379.     Pointer = Pointer + 1
  380.     If Pointer > MaxLines Then
  381.         Pointer = 1
  382.     End If
  383.  
  384.     'determine new acceleration
  385.     ax1 = Rnd - .5
  386.     ax2 = Rnd - .5
  387.     ay1 = Rnd - .5
  388.     ay2 = Rnd - .5
  389.  
  390.     'calculate new position
  391.     x1 = x1 + vx1
  392.     x2 = x2 + vx2
  393.     y1 = y1 + vy1
  394.     y2 = y2 + vy2
  395.  
  396.     'calculate new velocity
  397.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  398.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  399.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  400.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  401.  
  402.     'check if off screen
  403.     If (x1 > ScaleWidth) Then
  404.         'change direction
  405.         vx1 = -Abs(vx1)
  406.     ElseIf (x1 < 0) Then
  407.         'change direction
  408.         vx1 = Abs(vx1)
  409.     End If
  410.  
  411.     If (y1 > ScaleHeight) Then
  412.         'change direction
  413.         vy1 = -Abs(vy1)
  414.     ElseIf (y1 < 0) Then
  415.         'change direction
  416.         vy1 = Abs(vy1)
  417.     End If
  418.  
  419.     If (x2 > ScaleWidth) Then
  420.         'change direction
  421.         vx2 = -Abs(vx2)
  422.     ElseIf (x2 < 0) Then
  423.         'change direction
  424.         vx2 = Abs(vx2)
  425.     End If
  426.  
  427.     If (y2 > ScaleHeight) Then
  428.         'change direction
  429.         vy2 = -Abs(vy2)
  430.     ElseIf (y2 < 0) Then
  431.         'change direction
  432.         vy2 = Abs(vy2)
  433.     End If
  434.  
  435.  
  436.   End If
  437.  
  438. End Sub
  439.  
  440. Sub ClearScreen ()
  441. 'goes to extreme efforts to clear the screen
  442.  
  443.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  444.   'clear display
  445.   BitBlt DC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &H42&
  446.   i = DeleteDC(DC)
  447.  
  448.   picture = LoadPicture() ' clear picture
  449.   BackColor = QBColor(0)
  450.   Cls
  451.  
  452. End Sub
  453.  
  454. Sub Confetti ()
  455.  
  456.   'put points on screen
  457.   'Dim i As Integer, j As Integer, k As Integer
  458.   Dim x As Integer, y As Integer
  459.   Dim Size As Integer
  460.   Dim UniformBoxes As Integer
  461.  
  462.   ' if first time then initialize
  463.   If PlotInit = False Then
  464.     
  465.     'see if we need to reset changes made from previous init
  466.     If PlotEnd = False Then
  467.     
  468.       'check if saver is permitted to run
  469.       If CheckIfValidSaver(0) = 0 Then
  470.     Exit Sub
  471.       End If
  472.  
  473.      If LowMemoryFlag = 0 Then 'if not low memory mode then done
  474.        picture = original.Image ' start with original screen
  475.      Else
  476.        Cls
  477.      End If
  478.  
  479.       PlotInit = True
  480.       Size = Rnd * 5 + 1
  481.  
  482.     Else 'reset changes done by previous init
  483.  
  484.       Tick.Enabled = True
  485.       picture = LoadPicture()
  486.  
  487.     End If
  488.  
  489.   Else
  490.  
  491.     Tick.Enabled = False
  492.   
  493.     Size = Rnd * 5 + 1  ' size to make dots
  494.  
  495.     If Rnd > .5 Then
  496.        UniformBoxes = True
  497.     Else
  498.        UniformBoxes = False
  499.     End If
  500.  
  501.     Do
  502.       x = Int(Rnd * ScrnWidth)
  503.       y = Int(Rnd * ScrnHeight)
  504.       Line (x, y)-(x + Size, y + Size), GetNearestColor(hDC, RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))), BF
  505.  
  506.       If UniformBoxes = False Then
  507.     Size = Rnd ^ 10 * 40 + 2'new size
  508.       End If
  509.  
  510.       DoEvents
  511.       CurrentTime = Timer
  512.       If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Do
  513.     Loop
  514.  
  515.     Tick.Enabled = True
  516.     picture = LoadPicture()
  517.  
  518.   End If
  519.  
  520. End Sub
  521.  
  522. Sub CyclePalette ()
  523.  
  524.   Dim Header As Long, DataBits As Long, i As Integer, j As Integer
  525.   Dim l As Long
  526.   Dim Paint As PAINTSTRUCT
  527.   Static Xoffset As Integer, Yoffset As Integer, red As Integer, green As Integer, blue As Integer
  528.   Static Wdth As Integer, Hght As Integer
  529.   Static FastPalRunFlag As Integer, PassFlag As Integer
  530.   Dim FileName As String, File As String
  531.   Static PaletteFlag As Integer
  532.  
  533.   ' if first time then initialize
  534.   If PlotInit = False Then
  535.     
  536.     'see if we need to reset changes made from previous init
  537.     If PlotEnd = False Then
  538.     
  539.     'check if saver is permitted to run
  540.     If CheckIfValidSaver(1) = 0 Then
  541.       Exit Sub
  542.     End If
  543.  
  544.      'we only allow to run once since it has problems:
  545.      'if started more than once durring before program stops
  546.      'then resources can disappear drastically, there must
  547.      'be something about the animatepalette function or
  548.      'sendmessage that requires resources to be cleared?
  549.      If FastPalRunFlag Then
  550.        LogFile "Already ran Fast pallete cycle " + File, 1
  551.        NextSelection 'jump to next since there are no bitmap files in directory
  552.        Exit Sub
  553.      End If
  554.  
  555.       '*****************************************************
  556.       'initialization code here:
  557.       File = GetNextFile(CycleBitmapsDir, 1, "dib", "gif", "")
  558.  
  559.       If File = "" Then 'check if could not load
  560.     NextSelection 'jump to next since there are no bitmap files in directory
  561.     Exit Sub
  562.       End If
  563.  
  564.       ' find file
  565.       'FileSpec = RTrim$(BitmapsDir) + "\*.dib"
  566.       j = Rnd * 50 ' pick file at random
  567.       For i = 1 To j
  568.  
  569.     File = GetNextFile(CycleBitmapsDir, 0, "dib", "gif", "")' get next file
  570.  
  571.       Next i
  572.  
  573.       'i = LoadSlide(File, 1)
  574.       'If i = 0 Then 'check if could not load
  575.       '  LogFile "Could not load file " + File, 1
  576.       '  NextSelection 'jump to next since there are no bitmap files in directory
  577.       '  Exit Sub
  578.       'End If
  579.  
  580.       If InStr(UCase$(File), ".GIF") = 0 Then
  581.     l = ManyDibLoad(File, Wdth, Hght)'load dib
  582.       
  583.     If l <= 0 Then 'check if could not load
  584.       LogFile "Could not read DIB file " + File, 1
  585.       NextSelection 'jump to next since there are no bitmap files in directory
  586.       Exit Sub
  587.     End If
  588.       
  589.       Else
  590.     l = ManyGifLoad(File, Wdth, Hght)'load gif
  591.       
  592.     If l <= 0 Then 'check if could not load
  593.       LogFile "Could not read GIF file " + File, 1
  594.       NextSelection 'jump to next since there are no bitmap files in directory
  595.       Exit Sub
  596.     End If
  597.  
  598.       End If
  599.  
  600.       If (TotalNumColors <= 256) And (FastPaletteCycleFlag <> 0) Then
  601.  
  602.     FastPalRunFlag = 1
  603.  
  604.     'free up all but 2 system palettes
  605.     i = SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC)
  606.  
  607.     'show the palettes
  608.     SetWindow2DIBPalette PC_RESERVED
  609.     LogFile "Using Fast Palette Cycling", 0
  610.     PaletteFlag = 1
  611.  
  612.       Else 'don't mess with palettes
  613.  
  614.     'picture = LoadPicture() ' clear screen
  615.     LogFile "Changing Palette using screen redraws", 0
  616.     PaletteFlag = 0
  617.  
  618.       End If
  619.  
  620.       PassFlag = 2
  621.       
  622.       PlotInit = True
  623.       'Cls
  624.  
  625.       'position image
  626.       Xoffset = (ScrnWidth - Wdth) / 2
  627.       Yoffset = (ScrnHeight - Hght) / 2
  628.  
  629.       'set tick rate
  630.       Tick.Interval = 25
  631.  
  632.     Else 'reset changes done by previous init
  633.  
  634.       If PaletteFlag <> 0 Then
  635.  
  636.     'remove priority on palette entries
  637.     SetWindow2DIBPalette 0
  638.  
  639.     i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  640.  
  641.       End If
  642.  
  643.       'try to read last temp file for background
  644.       i = LoadSlideAndTile(RTrim$(BitmapsDir) + "\tmprary.dib")
  645.  
  646.       'save current screen as new original
  647.       DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  648.       BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  649.       i = DeleteDC(DC)
  650.  
  651.       ClearScreen
  652.  
  653.       i = ManyDibFree() 'free memory used for dib
  654.       If i <> 0 Then
  655.     LogFile "Could not free memory", 1
  656.       End If
  657.  
  658.       'set tick rate
  659.       Tick.Interval = 50
  660.  
  661.     End If
  662.  
  663.     
  664.   Else  ' put run code here
  665.  
  666.     If PassFlag > 1 Then
  667.  
  668.       Header = ManyDibGet() 'get pointer to header
  669.       DataBits = ManyDibGetData() 'get pointer to data
  670.  
  671.       If Header <> 0 Then
  672.  
  673.     i = SetStretchBltMode(hDC, 3)
  674.     i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, Wdth, Hght, DataBits, Header, 0, &HCC0020)'source copy
  675.       Else
  676.     LogFile "Header missing", 1
  677.     NextSelection
  678.     Exit Sub
  679.       End If
  680.  
  681.       PassFlag = PassFlag - 1
  682.     Else
  683.       
  684.       Header = ManyDibGet() 'get pointer to header
  685.       DataBits = ManyDibGetData() 'get pointer to data
  686.  
  687.       If Header <> 0 Then
  688.  
  689.     If PaletteFlag <> 0 Then
  690.  
  691.       DoAnimatePalette Pal, 1, 1'shift pallete by one
  692.  
  693.     Else 'if not palette based, animate screen by
  694.          'changing colors and redrawing
  695.          
  696.       'draw screen
  697.       i = SetStretchBltMode(hDC, 3)
  698.       ManyDibCyclePalette -1, 1, 255'cycle colors
  699.       'i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, 640, 480, DataBits, Header, 0, &HCC0020)'source copy
  700.       i = SetDIBitsToDevice(hDC, Xoffset, Yoffset, Wdth, Hght, 0, 0, 0, Hght, DataBits, Header, 0)
  701.  
  702.     End If
  703.     
  704.       Else
  705.     LogFile "Header missing", 1
  706.     NextSelection
  707.     Exit Sub
  708.       End If
  709.  
  710.     End If
  711.     
  712.   End If
  713.  
  714.   Exit Sub
  715.  
  716. End Sub
  717.  
  718. Sub DoAnimatePalette (palette As LOGPALETTE, Start As Integer, StepSize As Integer)
  719. ' cycle palete entry and display
  720.  
  721.     Dim entrynum%, i As Integer
  722.     Dim usepal As Integer
  723.     Dim holdentry As PALETTEENTRY
  724.     Dim temp As Long
  725.  
  726.     For i = 1 To StepSize'shift n times
  727.  
  728.       ' The following code simply loops the color values
  729.       LSet holdentry = palette.palPalEntry(Start)
  730.       For entrynum% = Start To PALENTRIES - 2
  731.     LSet palette.palPalEntry(entrynum%) = palette.palPalEntry(entrynum% + 1)
  732.       Next entrynum%
  733.       LSet palette.palPalEntry(PALENTRIES - 1) = holdentry
  734.  
  735.     Next i
  736.  
  737.     ' Get a handle to the control's palette
  738.     On Error GoTo 299
  739.     usepal = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  740.     On Error GoTo 0
  741.    
  742.     AnimatePalette usepal, 0, PALENTRIES, palette.palPalEntry(0)
  743.  
  744.     Exit Sub
  745.  
  746. 299 'overflow on getting palette handle
  747.   On Error GoTo 0
  748.   LogFile "Overflow on getting palette handle", 1
  749.   Exit Sub
  750. End Sub
  751.  
  752. Sub Dribble ()
  753.  
  754.   'dribbling paint on screen
  755.  
  756.   Dim i As Integer, j As Integer, k As Integer
  757.   Static MaxHole As Integer
  758.  
  759.   ' if first time then initialize
  760.   If PlotInit = False Then
  761.     
  762.     'see if we need to reset changes made from previous init
  763.     If PlotEnd = False Then
  764.     
  765.     'check if saver is permitted to run
  766.     If CheckIfValidSaver(1) = 0 Then
  767.       Exit Sub
  768.     End If
  769.     
  770.     ' start with original screen
  771.     picture = original.Image
  772.     
  773.     PlotInit = True
  774.  
  775.     'determine initial position of shot
  776.     x1 = Rnd * ScaleWidth
  777.     y1 = Rnd * ScaleHeight
  778.     
  779.     'Calculate velocity limits
  780.     MaxSpeedX = ScaleWidth * 20! / 800
  781.     MaxSpeedY = ScaleWidth * 20! / 600
  782.  
  783.     ' zero initial velocity
  784.     vx1 = 0: vy1 = 0
  785.  
  786.     'set maximum size of holes
  787.     MaxHole = 4
  788.  
  789.     ForeColor = RGB(0, 0, 0)' use black box
  790.     FillColor = RGB(0, 0, 0) 'set black fill
  791.     FillStyle = 0 'solid fill
  792.  
  793.     RunMode = Int(Rnd * 2#)'choose black or color
  794.  
  795.     'Debug.Print RunMode
  796.  
  797.     If RunMode > 0 Then ' if random color then use larger spots
  798.     MaxHole = 8
  799.     i = Rnd * 255: If i > 255 Then i = 255
  800.     j = Rnd * 255: If j > 255 Then j = 255
  801.     k = Rnd * 255: If k > 255 Then k = 255
  802.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  803.     FillColor = ForeColor
  804.     End If
  805.  
  806.   Else 'reset changes done by previous init
  807.  
  808.     ClearScreen
  809.     FillStyle = 1 'transparent fill
  810.  
  811.   End If
  812.  
  813.   Else  ' put run code here
  814.  
  815.     If RunMode > 0 Then ' see if need to change to random color
  816.  
  817.         If Rnd < .05 Then
  818.         i = Rnd * 255: If i > 255 Then i = 255
  819.         j = Rnd * 255: If j > 255 Then j = 255
  820.         k = Rnd * 255: If k > 255 Then k = 255
  821.         ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  822.         FillColor = ForeColor
  823.         End If
  824.  
  825.     End If
  826.     
  827.     ' put random hole here
  828.     Circle (x1 + Rnd * 20, y1 + Rnd * 20), MaxHole * Rnd + 2, , , , 1
  829.  
  830.     'determine new acceleration
  831.     ax1 = 2 * Rnd - 1
  832.     ay1 = 2 * Rnd - 1
  833.         
  834.     'calculate new position
  835.     x1 = x1 + vx1
  836.     y1 = y1 + vy1
  837.         
  838.     'calculate new velocity
  839.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ax1 = 0
  840.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ay1 = 0
  841.         
  842.     'check if off screen
  843.     If (x1 > ScaleWidth) Then
  844.         'change direction
  845.         vx1 = -Abs(vx1)
  846.     ElseIf (x1 < 0) Then
  847.         'change direction
  848.         vx1 = Abs(vx1)
  849.     End If
  850.  
  851.     If (y1 > ScaleHeight) Then
  852.         'change direction
  853.         vy1 = -Abs(vy1)
  854.     ElseIf (y1 < 0) Then
  855.         'change direction
  856.         vy1 = Abs(vy1)
  857.     End If
  858.  
  859.   End If
  860.  
  861. End Sub
  862.  
  863. Sub Drop ()
  864.  
  865.   ' bitblt's with various patterns, dragging them
  866.   ' across the screen randomly
  867.  
  868.   Dim j As Integer
  869.   Static OldY As Integer
  870.   Static NotFoundCount As Integer
  871.   Const MaxCount = 200
  872.  
  873.   ' if first time then initialize
  874.   If PlotInit = False Then
  875.  
  876.     'see if we need to reset changes made from previous init
  877.     If PlotEnd = False Then
  878.     
  879.     'check if saver is permitted to run
  880.     If CheckIfValidSaver(1) = 0 Then
  881.       Exit Sub
  882.     End If
  883.     
  884.     'store whether column has dropped
  885.     ReDim x1a(ScaleWidth)
  886.  
  887.     ' start with original screen
  888.     picture = original.Image
  889.  
  890.     PlotInit = True
  891.  
  892.     'flag that no column has been chosen
  893.     x1 = -1
  894.  
  895.     'Calculate velocity limits
  896.     MaxSpeedY = ScaleWidth * 10! / 600
  897.     MaxSpeedX = ScaleWidth * 10! / 800
  898.  
  899.     ' zero initial velocity
  900.     vy1 = 0
  901.  
  902.     'width of column to drop
  903.     BoxWidth = 10 + Rnd * 100
  904.  
  905.     i = Int(Rnd * 2#)'if i=0 then do jagged drop
  906.  
  907.     x2 = 0 'used for width change
  908.  
  909.   Else 'reset changes done by previous init
  910.  
  911.     'store whether column has dropped
  912.     ReDim x1a(0)
  913.     ClearScreen
  914.  
  915.   End If
  916.  
  917. Else  ' put run code here
  918.  
  919.   If x1 < 0 Then 'see if found valid column
  920.  
  921.     x1 = Rnd * ScaleWidth / BoxWidth 'choose a column
  922.     
  923.     If x1a(x1) = 0 Then 'check if not yet dropped
  924.     y1 = 0 'start position
  925.     x1a(x1) = 1 'flag that column has already been used
  926.     x2 = 0: vx2 = 0: OldY = 0' initialize variables
  927.     NotFoundCount = 0
  928.  
  929.     Else
  930.     x1 = -1 'flag that no column chosen
  931.  
  932.     ' count column failures
  933.     NotFoundCount = NotFoundCount + 1
  934.     If NotFoundCount > MaxCount Then
  935.     
  936.         'restart dropping
  937.  
  938.         'reset whether column has dropped
  939.         ReDim x1a(ScaleWidth)
  940.  
  941.         ' start with original screen
  942.         picture = original.Image
  943.  
  944.     End If
  945.     End If
  946.  
  947.   Else 'if column already found, then drop it
  948.  
  949.     If i = 0 Then 'check if jagged drop
  950.  
  951.     'make sure effective width does not get too small
  952.     If x2 >= BoxWidth - 5 Then
  953.     x2 = BoxWidth - 5
  954.     vx2 = -vx2 'reverse direction
  955.     End If
  956.  
  957.     j = x2 / 2 'get half of change
  958.  
  959.     'shift column
  960.     DC = original.hDC
  961.     BitBlt hDC, x1 * BoxWidth + j, y1, BoxWidth - x2, ScaleHeight - y1, DC, x1 * BoxWidth + j, 0, &HCC0020'source copy
  962.     
  963.     'blank top of column
  964.     BitBlt hDC, x1 * BoxWidth + j, OldY, BoxWidth - x2, y1 - OldY + 1, DC, x1 * BoxWidth + j, 0, &H42'blackout
  965.     
  966.     Else ' not jagged drop
  967.  
  968.     'shift column
  969.     DC = original.hDC
  970.     BitBlt hDC, x1 * BoxWidth, y1, BoxWidth, ScaleHeight - y1, DC, x1 * BoxWidth, 0, &HCC0020  'source copy
  971.     
  972.     'blank top of column
  973.     BitBlt hDC, x1 * BoxWidth, OldY, BoxWidth, y1 - OldY + 1, DC, x1 * BoxWidth, 0, &H42'blackout
  974.     
  975.     End If
  976.  
  977.     'save current position
  978.     OldY = y1
  979.  
  980.     'check if off screen
  981.     If (y1 > ScaleHeight) Then
  982.     x1 = -1 'flag done
  983.     vy1 = 0'zero velocity again
  984.     End If
  985.  
  986.     'determine new acceleration
  987.     ay1 = Rnd * .25
  988.     ax2 = Rnd * .25 - .125
  989.     
  990.     'calculate new positions
  991.     y1 = y1 + vy1
  992.     x2 = x2 + vx2
  993.     
  994.     'calculate new velocity
  995.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = vy1 / 2: ay1 = 0
  996.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = vx2 / 2: ax2 = 0
  997.     
  998.     End If
  999.  
  1000.   End If
  1001.  
  1002. End Sub
  1003.  
  1004. Sub EndScrnSaveForm ()
  1005.   LogFile "EndScrnSaveFrom: before freeing memory", 1
  1006.   i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  1007.  
  1008.   i = ManyDibFree() 'free memory used for dib
  1009.   If i <> 0 Then
  1010.     LogFile "Could not free memory", 1
  1011.   End If
  1012.  
  1013.   picture = LoadPicture()
  1014.   EndScrnSave 'call global screen saver
  1015. End Sub
  1016.  
  1017. Sub FilledCircles ()
  1018.   
  1019.   ' have a single filled elipse trace across the screen
  1020.  
  1021.   Dim i As Integer, j As Integer, k As Integer, n As Integer
  1022.   Dim xRadius As Integer, yRadius As Integer
  1023.  
  1024.   ' if first time then initialize
  1025.   If PlotInit = False Then
  1026.  
  1027.     'see if we need to reset changes made from previous init
  1028.     If PlotEnd = False Then
  1029.  
  1030.     'check if saver is permitted to run
  1031.     If CheckIfValidSaver(0) = 0 Then
  1032.       Exit Sub
  1033.     End If
  1034.     
  1035.     PlotInit = True
  1036.     Cls
  1037.     ForeColor = QBColor(15)
  1038.     FillColor = ForeColor
  1039.     BackColor = QBColor(0)
  1040.     FillStyle = 0' use solid fill
  1041.  
  1042.     ' set index to count number of times to repeat color
  1043.     '   to past maxvalue so that it will be recalculated
  1044.     RepeatIndex = MaxLines + 1
  1045.  
  1046.     'determine initial position of line
  1047.     x1 = Rnd * ScaleWidth
  1048.     x2 = Rnd * ScaleWidth
  1049.     y1 = Rnd * ScaleHeight
  1050.     y2 = Rnd * ScaleHeight
  1051.  
  1052.     'set initial velocity
  1053.     vx1 = 0
  1054.     vx2 = 0
  1055.     vy1 = 0
  1056.     vy2 = 0
  1057.  
  1058.     'set initial acceleration
  1059.     ax1 = 0
  1060.     ax2 = 0
  1061.     ay1 = 0
  1062.     ay2 = 0
  1063.     
  1064.     'find background color
  1065.     'Calculate velocity limits
  1066.     MaxSpeedX = ScaleWidth * 15! / 800
  1067.     MaxSpeedY = ScaleWidth * 15! / 600
  1068.  
  1069.   Else 'reset changes done by previous init
  1070.  
  1071.     ClearScreen
  1072.     FillStyle = 1 'transparent fill
  1073.  
  1074.   End If
  1075.  
  1076.   Else  ' put run code here
  1077.  
  1078.     ' check if time to get a new color
  1079.     If RepeatIndex > RepeatCount Then
  1080.     
  1081.     ' get random fore ground color
  1082.     i = Rnd * 255: If i > 255 Then i = 255
  1083.     j = Rnd * 255: If j > 255 Then j = 255
  1084.     k = Rnd * 255: If k > 255 Then k = 255
  1085.     ForeColor = RGB(i, j, k)
  1086.  
  1087.     ' get random fill color
  1088.     i = Rnd * 255: If i > 255 Then i = 255
  1089.     j = Rnd * 255: If j > 255 Then j = 255
  1090.     k = Rnd * 255: If k > 255 Then k = 255
  1091.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  1092.  
  1093.     RepeatIndex = 1
  1094.     Else
  1095.     RepeatIndex = RepeatIndex + 1
  1096.     End If
  1097.  
  1098.     'Draw new Circle
  1099.     xRadius = Abs(x1 - x2) / 2
  1100.     yRadius = Abs(y1 - y2) / 2
  1101.     If xRadius <> 0 Then
  1102.         Circle ((x1 + x2) / 2, (y1 + y2) / 2), xRadius, , , , yRadius / xRadius
  1103.     End If
  1104.  
  1105.     'Move pointer to next item
  1106.     Pointer = Pointer + 1
  1107.     If Pointer > MaxLines Then
  1108.         Pointer = 1
  1109.     End If
  1110.  
  1111.     'determine new acceleration
  1112.     ax1 = Rnd - .5
  1113.     ax2 = Rnd - .5
  1114.     ay1 = Rnd - .5
  1115.     ay2 = Rnd - .5
  1116.  
  1117.     'calculate new position
  1118.     x1 = x1 + vx1
  1119.     x2 = x2 + vx2
  1120.     y1 = y1 + vy1
  1121.     y2 = y2 + vy2
  1122.  
  1123.     'calculate new velocity
  1124.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1125.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1126.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1127.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1128.  
  1129.     'check if off screen
  1130.     If (x1 > ScaleWidth) Then
  1131.         'change direction
  1132.         vx1 = -Abs(vx1)
  1133.     ElseIf (x1 < 0) Then
  1134.         'change direction
  1135.         vx1 = Abs(vx1)
  1136.     End If
  1137.  
  1138.     If (y1 > ScaleHeight) Then
  1139.         'change direction
  1140.         vy1 = -Abs(vy1)
  1141.     ElseIf (y1 < 0) Then
  1142.         'change direction
  1143.         vy1 = Abs(vy1)
  1144.     End If
  1145.  
  1146.     If (x2 > ScaleWidth) Then
  1147.         'change direction
  1148.         vx2 = -Abs(vx2)
  1149.     ElseIf (x2 < 0) Then
  1150.         'change direction
  1151.         vx2 = Abs(vx2)
  1152.     End If
  1153.  
  1154.     If (y2 > ScaleHeight) Then
  1155.         'change direction
  1156.         vy2 = -Abs(vy2)
  1157.     ElseIf (y2 < 0) Then
  1158.         'change direction
  1159.         vy2 = Abs(vy2)
  1160.     End If
  1161.  
  1162.  
  1163.   End If
  1164.  
  1165.  
  1166. End Sub
  1167.  
  1168. Sub FilledPolygons ()
  1169.  
  1170.   ' draw a randomly moving polygon on the screen
  1171.   ' slightly offset from previous polygon
  1172.  
  1173.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  1174.   Static Sets As Integer
  1175.   
  1176.   ' if first time then initialize
  1177.   If PlotInit = False Then
  1178.     
  1179.     'see if we need to reset changes made from previous init
  1180.     If PlotEnd = False Then
  1181.     
  1182.     'check if saver is permitted to run
  1183.     If CheckIfValidSaver(0) = 0 Then
  1184.       Exit Sub
  1185.     End If
  1186.     
  1187.     PlotInit = True
  1188.     ForeColor = RGB(255, 255, 255)
  1189.     BackColor = RGB(0, 0, 0)
  1190.     FillStyle = 0' use solid fill
  1191.     DrawWidth = 1' use narrow line
  1192.     j = SetPolyFillMode(hDC, 2)' use winding fill mode
  1193.     Cls
  1194.  
  1195.     'set number of corners between 3 and 5
  1196.     Sets = Rnd * 4 + 3
  1197.  
  1198.     'Set array size and clear the elements
  1199.     ReDim Points(Sets) As POINTAPI
  1200.     ReDim vx1sa(Sets) As Single
  1201.     ReDim vy1sa(Sets) As Single
  1202.     ReDim ax1sa(Sets) As Single
  1203.     ReDim ay1sa(Sets) As Single
  1204.     
  1205.     'counter for changing colors, set to overflow
  1206.     RepeatIndex = RepeatCount + 1
  1207.     
  1208.     For j = 1 To Sets
  1209.  
  1210.     'determine initial position of line
  1211.     Points(j).x = Rnd * ScaleWidth
  1212.     Points(j).y = Rnd * ScaleHeight
  1213.  
  1214.     Next j
  1215.     
  1216.     'Calculate velocity limits
  1217.     MaxSpeedX = ScaleWidth * 15! / 800
  1218.     MaxSpeedY = ScaleWidth * 15! / 600
  1219.  
  1220.   Else 'reset changes done by previous init
  1221.  
  1222.     ReDim Points(0) As POINTAPI
  1223.     ReDim vx1sa(0) As Single
  1224.     ReDim vy1sa(0) As Single
  1225.     ReDim ax1sa(0) As Single
  1226.     ReDim ay1sa(0) As Single
  1227.  
  1228.     FillStyle = 1 'transparent fill
  1229.     j = SetPolyFillMode(hDC, 1)' reset to alternate fill mode
  1230.     ClearScreen
  1231.  
  1232.   End If
  1233.  
  1234.   Else  ' put run code here
  1235.  
  1236.  
  1237.     ' check if time to get a new color
  1238.     If RepeatIndex > RepeatCount Then
  1239.     
  1240.     'set fill color
  1241.     i = Rnd * 255: If i > 255 Then i = 255
  1242.     j = Rnd * 255: If j > 255 Then j = 255
  1243.     k = Rnd * 255: If k > 255 Then k = 255
  1244.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  1245.     
  1246.     'set foreground color
  1247.     i = Rnd * 255: If i > 255 Then i = 255
  1248.     j = Rnd * 255: If j > 255 Then j = 255
  1249.     k = Rnd * 255: If k > 255 Then k = 255
  1250.     ForeColor = RGB(i, j, k)
  1251.     
  1252.     RepeatIndex = 1
  1253.     Else
  1254.     RepeatIndex = RepeatIndex + 1
  1255.     End If
  1256.  
  1257.  
  1258.     'Draw polygon
  1259.     j = Polygon(hDC, Points(0), Sets)
  1260.  
  1261.     For j = 1 To Sets
  1262.  
  1263.         'determine new acceleration
  1264.         ax1sa(j) = Rnd - .5
  1265.         ay1sa(j) = Rnd - .5
  1266.         
  1267.         'calculate new position
  1268.         Points(j).x = Points(j).x + vx1sa(j)
  1269.         Points(j).y = Points(j).y + vy1sa(j)
  1270.  
  1271.         'calculate new velocity
  1272.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  1273.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  1274.  
  1275.         'check if off screen
  1276.         If (Points(j).x > ScaleWidth) Then
  1277.         'change direction
  1278.         vx1sa(j) = -Abs(vx1sa(j))
  1279.         ElseIf (Points(j).x < 0) Then
  1280.         'change direction
  1281.         vx1sa(j) = Abs(vx1sa(j))
  1282.         End If
  1283.  
  1284.         If (Points(j).y > ScaleHeight) Then
  1285.         'change direction
  1286.         vy1sa(j) = -Abs(vy1sa(j))
  1287.         ElseIf (Points(j).y < 0) Then
  1288.         'change direction
  1289.         vy1sa(j) = Abs(vy1sa(j))
  1290.         End If
  1291.  
  1292.     Next j
  1293.     
  1294.     End If
  1295.  
  1296.  
  1297. End Sub
  1298.  
  1299. '
  1300. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  1301.     
  1302.     Static KeyState As String * 257
  1303.     Dim LongChar As Long
  1304.     Dim KeyAscii As Integer
  1305.     Static temp$    ' Collects characters each time key is pressed.
  1306.  
  1307.  
  1308.     If Passwd = "" Then
  1309.  
  1310.     LogFile ("KeyDown, Terminating"), 0
  1311.     EndScrnSaveForm         ' End screen blanking
  1312.  
  1313.     Else
  1314.  
  1315.     'refresh system modal in case another process
  1316.     'has grabbed it
  1317.     If TestMode = 0 Then
  1318.         ZOrder 0' make sure form is still on top
  1319.         i = SetSysModalWindow(hWnd)
  1320.     End If
  1321.     
  1322.     'refresh password box
  1323.     PasswordLabel.Visible = False
  1324.     PasswordLabel.Visible = True
  1325.  
  1326.     'convert key to ascii
  1327.     'GetKeyboardStateBystring (KeyState)' get kb state
  1328.     'i = ToAsciiBystring(KeyCode, 0, KeyState, LongChar, 0)
  1329.     'KeyAscii = LongChar Mod 256
  1330.     KeyAscii = MapVirtualKey(KeyCode, 2) ' convert virtual key code to ascii
  1331.  
  1332.     LogFile ("KeyDown, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received, translated to '" + Chr$(KeyAscii) + "' (" + Str$(KeyAscii) + ")"), 0
  1333.  
  1334.     KeyCode = 0' clear key
  1335.  
  1336.     'parse key into password
  1337.     If KeyAscii = 13 Then       ' ENTER key pressed.
  1338.        KeyAscii = 0            ' Prevents Beep after ENTER Key.
  1339.        If temp$ = Passwd Then
  1340.          LogFile ("Password entered, Terminating"), 0
  1341.          EndScrnSaveForm          ' End screen blanking
  1342.        Else
  1343.          temp$ = ""
  1344.          LogFile ("Invalid Password entered, Continuing"), 0
  1345.          PasswordLabel.Caption = "Password Invalid  "
  1346.          Beep  ' Signal user that password failed.
  1347.          Exit Sub
  1348.        End If
  1349.  
  1350.     ElseIf KeyAscii = 8 Then    ' Backspace key pressed.
  1351.        KeyAscii = 0            'character is not passed on
  1352.        If temp$ <> "" Then 'only delete if not empty
  1353.          temp$ = Left$(temp$, Len(temp$) - 1) ' Remove one char.
  1354.        Else
  1355.          Beep
  1356.        End If
  1357.     
  1358.     ElseIf Len(temp$) = NUMCHARS Then      ' Limit size of password.
  1359.        KeyAscii = 0
  1360.        Beep                    ' Signal user that field is full.
  1361.  
  1362.     ElseIf KeyAscii < 32 Then  ' ignore control keys
  1363.        KeyAscii = 0            ' character is not passed on
  1364.  
  1365.     Else 'normal character that we can recognize?
  1366.        temp$ = temp$ + UCase$(Chr$(KeyAscii))    ' Add a character.
  1367.        KeyAscii = 0            'character is not passed on
  1368.     End If
  1369.  
  1370.     PasswordLabel.Caption = "Password>" + String$(Len(temp$), "*")
  1371.  
  1372.     End If
  1373.  
  1374. End Sub
  1375.  
  1376. Sub Form_KeyPress (KeyAscii As Integer)
  1377.  
  1378.     If Passwd <> "" Then
  1379.  
  1380.     'refresh system modal in case another process
  1381.     'has grabbed it
  1382.     If TestMode = 0 Then
  1383.        ZOrder 0' make sure form is still on top
  1384.        i = SetSysModalWindow(hWnd)
  1385.     End If
  1386.  
  1387.        'refresh password box
  1388.        PasswordLabel.Visible = False
  1389.        PasswordLabel.Visible = True
  1390.  
  1391.        LogFile ("KeyPress, '" + Chr$(KeyAscii) + "' received, code(" + Str$(KeyAscii) + ")"), 0
  1392.        KeyAscii = 0 ' trap characters
  1393.  
  1394.     Else
  1395.  
  1396.     LogFile ("KeyPress, Terminating"), 0
  1397.     EndScrnSaveForm            ' End screen blanking
  1398.  
  1399.     End If
  1400.  
  1401. End Sub
  1402.  
  1403. Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
  1404.  
  1405. LogFile ("KeyUp, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received"), 0
  1406.  
  1407. End Sub
  1408.  
  1409. Sub Form_Load ()
  1410.  
  1411.     ' stretch to full screen
  1412.     Move 0, 0, screen.Width, screen.Height
  1413.  
  1414.     TotalNumColors = GetNumberOfColors()'read number colors display can handle
  1415.     LogFile "Display supports " + Str$(TotalNumColors) + " colors", 0
  1416.  
  1417.     KeyPreview = True 'form takes priority on keys
  1418.     
  1419.     'set system modal
  1420.     If TestMode = 0 Then
  1421.       ZOrder 0' make sure form is still on top
  1422.       i = SetSysModalWindow(hWnd) 'make sure can't CTL-ALT-DEL out
  1423.     End If
  1424.  
  1425.     'make mouse invisible
  1426.     If TestMode = 0 Then
  1427.       HideMouse
  1428.     End If
  1429.  
  1430.     'tell windows to disable screen savers
  1431.     i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, False, 0, 0)
  1432.     
  1433.     DrawWidth = 1
  1434.  
  1435.     Randomize
  1436.  
  1437.     MaxPlotType = 21
  1438.     ReadPriorities ' call each Plot type to get its priority
  1439.  
  1440.     ' Initialize variables now
  1441.     'set plot type
  1442.     If StartSaver = 0 Then
  1443.       PlotType = MaxPlotType * Rnd
  1444.     Else
  1445.       PlotType = StartSaver
  1446.     End If
  1447.  
  1448.     If PlotType > MaxPlotType Then PlotType = 1
  1449.  
  1450.     LogFile ("First Saver is " + Str$(PlotType)), 1
  1451.  
  1452.     PlotInit = False
  1453.     PlotEnd = False
  1454.  
  1455.     TimeInterval = 0
  1456.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  1457.  
  1458.     'set tick rate
  1459.     Tick.Interval = 50
  1460.  
  1461.     Repeats = 1 ' number of drawings to make before returning
  1462.  
  1463.     Tick.Enabled = True
  1464.  
  1465. End Sub
  1466.  
  1467. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  1468.  
  1469.     If IsEmpty(MouseX) Or IsEmpty(MouseY) Then
  1470.     MouseX = x
  1471.     MouseY = y
  1472.     LogFile ("First Mouse Movement (" + Str$(x) + "," + Str$(y) + ")"), 0
  1473.     End If
  1474.  
  1475.     '
  1476.     ' Only unblank the screen if the mouse moves quickly
  1477.     ' enough (more than 2 pixels at one time.
  1478.     '
  1479.     If Abs(MouseX - x) > 2 Or Abs(MouseY - y) > 2 Then
  1480.        
  1481.       If Passwd = "" Then ' only exit if no password
  1482.  
  1483.      LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Terminating"), 0
  1484.      LogFile ("Old Pos (" + Str$(MouseX) + "," + Str$(MouseY) + "), Terminating"), 0
  1485.      EndScrnSaveForm          ' End screen blanking
  1486.  
  1487.       Else
  1488.  
  1489.     'refresh system modal in case another process
  1490.     'has grabbed it
  1491.     If TestMode = 0 Then
  1492.         i = SetSysModalWindow(hWnd)
  1493.     End If
  1494.  
  1495.     PasswordLabel.Visible = False
  1496.     PasswordLabel.Visible = True
  1497.  
  1498.       End If
  1499.  
  1500.     End If
  1501.     LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Continuing"), 0
  1502.     MouseX = x                   ' Remember last position
  1503.     MouseY = y
  1504.  
  1505. End Sub
  1506.  
  1507. Sub Form_Paint ()
  1508.     
  1509.     ' stretch to full screen
  1510.     Move 0, 0, screen.Width, screen.Height
  1511.  
  1512. End Sub
  1513.  
  1514. Function GetBrightNonGray () As Long
  1515.  
  1516. ' this function is needed because in 256 color mode
  1517. ' many random colors get mapped to grays
  1518.  
  1519.   Dim i As Long, j As Long, k As Long
  1520.   Dim NewColor As Long
  1521.  
  1522.   Do
  1523.     i = Rnd * 255: If i > 255 Then i = 255
  1524.     j = Rnd * 255: If j > 255 Then j = 255
  1525.     k = Rnd * 255: If k > 255 Then k = 255
  1526.  
  1527.     'LogFile ("GetBrightNonGray testing color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1528.  
  1529.     'get nearest colors
  1530.     NewColor = GetNearestColor(hDC, RGB(i, j, k))
  1531.     i = NewColor And &HFF
  1532.     j = NewColor \ &H100 And &HFF
  1533.     k = NewColor \ &H10000 And &HFF
  1534.  
  1535.     'LogFile ("GetBrightNonGray nearest color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1536.  
  1537.     'make sure color is sufficiently bright, and not too gray
  1538.     Loop Until ((i * i + j * j + k * k) > MinColor) And ((Abs(i - j) > MinDiff) Or (Abs(j - k) > MinDiff))
  1539.  
  1540.   'LogFile ("GetBrightNonGray using color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1541.   GetBrightNonGray = NewColor
  1542.  
  1543. End Function
  1544.  
  1545. Function GetNumberOfColors () As Single
  1546.  
  1547.   Dim i As Integer, j As Integer, k As Integer
  1548.  
  1549.   ' get bits per pixel per plane
  1550.   i = GetDeviceCaps(hDC, BITSPIXEL)
  1551.   ' get number of planes
  1552.   j = GetDeviceCaps(hDC, PLANES)
  1553.   ' get total bits per pixel
  1554.   k = i * j
  1555.   GetNumberOfColors = 2# ^ k
  1556. End Function
  1557.  
  1558. Function GetSize (FileName$) As Integer
  1559.     
  1560.     Dim InLine$
  1561.     Dim Loaded As Integer
  1562.  
  1563.     Open FileName$ For Binary As #1
  1564.  
  1565.     '*****************************************************
  1566.     'read header
  1567.     InLine$ = Input$(26, 1)
  1568.     
  1569.     If Asc(Mid$(InLine$, 1, 1)) <> &H42 Then GoTo errorexit
  1570.     If Asc(Mid$(InLine$, 2, 1)) <> &H4D Then GoTo errorexit
  1571.  
  1572.     PicWidth = Asc(Mid$(InLine$, 19, 1)) + Asc(Mid$(InLine$, 20, 1)) * 256
  1573.     PicHeight = Asc(Mid$(InLine$, 23, 1)) + Asc(Mid$(InLine$, 24, 1)) * 256
  1574.  
  1575.     'Debug.Print SWidth, SHeight
  1576.  
  1577.     Close #1
  1578.  
  1579.     Loaded = 1 'flag good read
  1580.  
  1581.     GoTo regexit
  1582.  
  1583. errorexit: Loaded = 0
  1584. regexit: ' no error exit
  1585.     GetSize = Loaded'return read state
  1586. End Function
  1587.  
  1588. Sub Kalied ()
  1589.   
  1590.   ' have a line and its mirror images trace across the
  1591.   ' screen with multiple previous copies following
  1592.   ' it
  1593.  
  1594.   Dim xRadius As Integer, yRadius As Integer
  1595.   Static OldWidth As Integer, OldHeight As Integer
  1596.   Static OldLeft As Integer, OldTop As Integer
  1597.   Static Discontinuous As Integer
  1598.  
  1599.   ' if first time then initialize
  1600.   If PlotInit = False Then
  1601.     
  1602.    'see if we need to reset changes made from previous init
  1603.    If PlotEnd = False Then
  1604.     
  1605.     'check if saver is permitted to run
  1606.     If CheckIfValidSaver(0) = 0 Then
  1607.       Exit Sub
  1608.     End If
  1609.     
  1610.     PlotInit = True
  1611.     Cls
  1612.     ForeColor = QBColor(15)
  1613.  
  1614.     If Rnd > .5 Then
  1615.       Discontinuous = False
  1616.     Else
  1617.       Discontinuous = True
  1618.     End If
  1619.  
  1620.     'select mirroring method
  1621.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1622.  
  1623.     'Set array size and clear the elements
  1624.     ReDim x1a(MaxLines) As Integer
  1625.     ReDim x2a(MaxLines) As Integer
  1626.     ReDim y1a(MaxLines) As Integer
  1627.     ReDim y2a(MaxLines) As Integer
  1628.  
  1629.     Pointer = 1     ' start with array element 1
  1630.     
  1631.     ' set index to count number of times to repeat color
  1632.     '   to past maxvalue so that it will be recalculated
  1633.     RepeatIndex = MaxLines + 1
  1634.  
  1635.     'save old
  1636.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1637.     OldLeft = Scaleleft: OldTop = Scaletop
  1638.  
  1639.     'change scaleso they are symetrical:
  1640.     ScaleHeight = ScaleWidth
  1641.     Scaleleft = -ScaleHeight / 2
  1642.     Scaletop = Scaleleft
  1643.  
  1644.     'Calculate velocity limits
  1645.     MaxSpeedX = ScaleWidth * 15! / 800
  1646.     MaxSpeedY = ScaleWidth * 15! / 600
  1647.  
  1648.     'determine initial position of line
  1649.     x1 = (Rnd - .5) * ScaleWidth
  1650.     x2 = (Rnd - .5) * ScaleWidth
  1651.     y1 = (Rnd - .5) * ScaleHeight
  1652.     y2 = (Rnd - .5) * ScaleHeight
  1653.  
  1654.     'set initial velocity
  1655.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1656.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1657.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1658.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1659.  
  1660.     'set initial acceleration
  1661.     ax1 = 0
  1662.     ax2 = 0
  1663.     ay1 = 0
  1664.     ay2 = 0
  1665.     
  1666.     'find background color
  1667.     m = QBColor(0)
  1668.  
  1669.     'set tick rate
  1670.     Tick.Interval = 50
  1671.  
  1672.  
  1673.   Else 'reset changes done by previous init
  1674.  
  1675.     'reset tick rate
  1676.     Tick.Interval = 50
  1677.  
  1678.     'zero array sizes
  1679.     ReDim x1a(0) As Integer
  1680.     ReDim x2a(0) As Integer
  1681.     ReDim y1a(0) As Integer
  1682.     ReDim y2a(0) As Integer
  1683.  
  1684.       'reset screen dimensions
  1685.       ScaleWidth = OldWidth
  1686.       ScaleHeight = OldHeight
  1687.       Scaleleft = OldLeft
  1688.       Scaletop = OldTop
  1689.  
  1690.     ClearScreen
  1691.  
  1692.   End If
  1693.  
  1694.   Else  ' put run code here
  1695.  
  1696.  
  1697.     ' check if time to get a new color
  1698.     If RepeatIndex > RepeatCount Then
  1699.     
  1700.     ' get color
  1701.     l = GetBrightNonGray()
  1702.  
  1703.     If Discontinuous = True Then
  1704.  
  1705.       'determine new position of line
  1706.       x1 = (Rnd - .5) * ScaleWidth
  1707.       x2 = (Rnd - .5) * ScaleWidth
  1708.       y1 = (Rnd - .5) * ScaleHeight
  1709.       y2 = (Rnd - .5) * ScaleHeight
  1710.  
  1711.       'set new velocity
  1712.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1713.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1714.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1715.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1716.  
  1717.       'clear acceleration
  1718.       ax1 = 0
  1719.       ax2 = 0
  1720.       ay1 = 0
  1721.       ay2 = 0
  1722.     
  1723.     End If
  1724.  
  1725.     RepeatIndex = 1
  1726.     Else
  1727.     RepeatIndex = RepeatIndex + 1
  1728.     End If
  1729.  
  1730.     'Delete original Lines
  1731.     KaliedPlot Mirror, x1a(Pointer), y1a(Pointer), x2a(Pointer), y2a(Pointer), m
  1732.  
  1733.     'Save New Lines
  1734.     x1a(Pointer) = x1
  1735.     x2a(Pointer) = x2
  1736.     y1a(Pointer) = y1
  1737.     y2a(Pointer) = y2
  1738.  
  1739.     DoEvents
  1740.  
  1741.     'Draw New Lines
  1742.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1743.  
  1744.     'Move pointer to next item
  1745.     Pointer = Pointer + 1
  1746.     If Pointer > MaxLines Then
  1747.         Pointer = 1
  1748.     End If
  1749.  
  1750.     'determine new acceleration
  1751.     ax1 = Rnd - .5
  1752.     ax2 = Rnd - .5
  1753.     ay1 = Rnd - .5
  1754.     ay2 = Rnd - .5
  1755.  
  1756.     'calculate new position
  1757.     x1 = x1 + vx1
  1758.     x2 = x2 + vx2
  1759.     y1 = y1 + vy1
  1760.     y2 = y2 + vy2
  1761.  
  1762.     'calculate new velocity
  1763.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1764.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1765.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1766.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1767.  
  1768.     'check if off screen
  1769.     If (x1 > -Scaleleft) Then
  1770.         'change direction
  1771.         vx1 = -Abs(vx1)
  1772.     ElseIf (x1 < Scaleleft) Then
  1773.         'change direction
  1774.         vx1 = Abs(vx1)
  1775.     End If
  1776.  
  1777.     If (y1 > -Scaletop) Then
  1778.         'change direction
  1779.         vy1 = -Abs(vy1)
  1780.     ElseIf (y1 < Scaletop) Then
  1781.         'change direction
  1782.         vy1 = Abs(vy1)
  1783.     End If
  1784.  
  1785.     If (x2 > -Scaleleft) Then
  1786.         'change direction
  1787.         vx2 = -Abs(vx2)
  1788.     ElseIf (x2 < Scaleleft) Then
  1789.         'change direction
  1790.         vx2 = Abs(vx2)
  1791.     End If
  1792.  
  1793.     If (y2 > -Scaletop) Then
  1794.         'change direction
  1795.         vy2 = -Abs(vy2)
  1796.     ElseIf (y2 < Scaletop) Then
  1797.         'change direction
  1798.         vy2 = Abs(vy2)
  1799.     End If
  1800.  
  1801.     
  1802.     
  1803.     End If
  1804.  
  1805. End Sub
  1806.  
  1807. Sub Kalied2 ()
  1808.   
  1809.   ' have a line and its mirror images trace across the
  1810.   ' screen with all the previous copies left on the screen
  1811.   ' until the maximum is reached and the screen cleared
  1812.  
  1813.   Dim xRadius As Integer, yRadius As Integer
  1814.   Static OldWidth As Integer, OldHeight As Integer
  1815.   Static OldLeft As Integer, OldTop As Integer
  1816.   Static Discontinuous As Integer
  1817.  
  1818.   ' if first time then initialize
  1819.   If PlotInit = False Then
  1820.     
  1821.     'see if we need to reset changes made from previous init
  1822.     If PlotEnd = True Then
  1823.       ScaleWidth = OldWidth
  1824.       ScaleHeight = OldHeight
  1825.       Scaleleft = OldLeft
  1826.       Scaletop = OldTop
  1827.       ClearScreen
  1828.       Exit Sub
  1829.     End If
  1830.     
  1831.     'check if saver is permitted to run
  1832.     If CheckIfValidSaver(0) = 0 Then
  1833.       Exit Sub
  1834.     End If
  1835.     
  1836.     PlotInit = True
  1837.     Cls
  1838.     ForeColor = QBColor(15)
  1839.  
  1840.     If Rnd > .5 Then
  1841.       Discontinuous = False
  1842.     Else
  1843.       Discontinuous = True
  1844.     End If
  1845.  
  1846.     'select mirroring method
  1847.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1848.  
  1849.     Pointer = 1     ' set lines on screen to one
  1850.     
  1851.     ' set index to count number of times to repeat color
  1852.     '   to past maxvalue so that it will be recalculated
  1853.     RepeatIndex = MaxLines + 1
  1854.  
  1855.     'save old
  1856.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1857.     OldLeft = Scaleleft: OldTop = Scaletop
  1858.  
  1859.     'change scaleso they are symetrical:
  1860.     ScaleHeight = ScaleWidth
  1861.     Scaleleft = -ScaleHeight / 2
  1862.     Scaletop = Scaleleft
  1863.  
  1864.     'determine initial position of line
  1865.     x1 = (Rnd - .5) * ScaleWidth
  1866.     x2 = (Rnd - .5) * ScaleWidth
  1867.     y1 = (Rnd - .5) * ScaleHeight
  1868.     y2 = (Rnd - .5) * ScaleHeight
  1869.  
  1870.     'set initial velocity
  1871.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1872.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1873.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1874.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1875.  
  1876.     'set initial acceleration
  1877.     ax1 = 0
  1878.     ax2 = 0
  1879.     ay1 = 0
  1880.     ay2 = 0
  1881.     
  1882.     'find background color
  1883.     m = QBColor(0)
  1884.  
  1885.     'Calculate velocity limits
  1886.     MaxSpeedX = ScaleWidth * 15! / 800
  1887.     MaxSpeedY = ScaleWidth * 15! / 600
  1888.  
  1889.   Else  ' put run code here
  1890.  
  1891.  
  1892.     ' check if time to get a new color
  1893.     If RepeatIndex > RepeatCount Then
  1894.     
  1895.     ' get color
  1896.     l = GetBrightNonGray()
  1897.  
  1898.     If Discontinuous = True Then
  1899.  
  1900.       'determine new position of line
  1901.       x1 = (Rnd - .5) * ScaleWidth
  1902.       x2 = (Rnd - .5) * ScaleWidth
  1903.       y1 = (Rnd - .5) * ScaleHeight
  1904.       y2 = (Rnd - .5) * ScaleHeight
  1905.  
  1906.       'set new velocity
  1907.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1908.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1909.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1910.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1911.  
  1912.       'clear acceleration
  1913.       ax1 = 0
  1914.       ax2 = 0
  1915.       ay1 = 0
  1916.       ay2 = 0
  1917.     
  1918.     End If
  1919.  
  1920.     RepeatIndex = 1
  1921.     Else
  1922.     RepeatIndex = RepeatIndex + 1
  1923.     End If
  1924.  
  1925.     'Draw New Lines
  1926.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1927.  
  1928.     ' count total lines on screen
  1929.     Pointer = Pointer + 1
  1930.     If Pointer > MaxCums Then
  1931.         'when maximum reached then clear
  1932.         Cls
  1933.         Pointer = 1
  1934.     End If
  1935.  
  1936.     'determine new acceleration
  1937.     ax1 = Rnd - .5
  1938.     ax2 = Rnd - .5
  1939.     ay1 = Rnd - .5
  1940.     ay2 = Rnd - .5
  1941.  
  1942.     'calculate new position
  1943.     x1 = x1 + vx1
  1944.     x2 = x2 + vx2
  1945.     y1 = y1 + vy1
  1946.     y2 = y2 + vy2
  1947.  
  1948.     'calculate new velocity
  1949.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1950.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1951.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1952.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1953.  
  1954.     'check if off screen
  1955.     If (x1 > -Scaleleft) Then
  1956.         'change direction
  1957.         vx1 = -Abs(vx1)
  1958.     ElseIf (x1 < Scaleleft) Then
  1959.         'change direction
  1960.         vx1 = Abs(vx1)
  1961.     End If
  1962.  
  1963.     If (y1 > -Scaletop) Then
  1964.         'change direction
  1965.         vy1 = -Abs(vy1)
  1966.     ElseIf (y1 < Scaletop) Then
  1967.         'change direction
  1968.         vy1 = Abs(vy1)
  1969.     End If
  1970.  
  1971.     If (x2 > -Scaleleft) Then
  1972.         'change direction
  1973.         vx2 = -Abs(vx2)
  1974.     ElseIf (x2 < Scaleleft) Then
  1975.         'change direction
  1976.         vx2 = Abs(vx2)
  1977.     End If
  1978.  
  1979.     If (y2 > -Scaletop) Then
  1980.         'change direction
  1981.         vy2 = -Abs(vy2)
  1982.     ElseIf (y2 < Scaletop) Then
  1983.         'change direction
  1984.         vy2 = Abs(vy2)
  1985.     End If
  1986.  
  1987.     
  1988.     End If
  1989.  
  1990.  
  1991. End Sub
  1992.  
  1993. Sub KaliedPlot (MirrorMode As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Color As Long)
  1994.  
  1995. 'warning -- recursive subroutine
  1996.  
  1997.   Dim xm1 As Integer, ym1 As Integer, xm2 As Integer, ym2 As Integer
  1998.  
  1999.     Select Case MirrorMode
  2000.     Case 1: 'mirror on x and y axis
  2001.         Line (x1, y1)-(x2, y2), Color
  2002.         Line (-x1, y1)-(-x2, y2), Color
  2003.         Line (x1, -y1)-(x2, -y2), Color
  2004.         Line (-x1, -y1)-(-x2, -y2), Color
  2005.  
  2006.     Case 2: 'mirror on Y axis
  2007.         Line (x1, y1)-(x2, y2), Color
  2008.         Line (-x1, y1)-(-x2, y2), Color
  2009.  
  2010.     Case 3: 'mirror around center point
  2011.         Line (x1, y1)-(x2, y2), Color
  2012.         Line (-x1, -y1)-(-x2, -y2), Color
  2013.  
  2014.     Case 4: 'mirror around center point and diagonally
  2015.         Line (x1, y1)-(x2, y2), Color
  2016.         Line (-x1, -y1)-(-x2, -y2), Color
  2017.  
  2018.         'mirror diagonally
  2019.         xm1 = y1
  2020.         ym1 = x1
  2021.         xm2 = y2
  2022.         ym2 = x2
  2023.         Line (-xm1, ym1)-(-xm2, ym2), Color
  2024.         Line (xm1, -ym1)-(xm2, -ym2), Color
  2025.  
  2026.     Case 5: 'mirror on x and y axis and diagonally
  2027.         Line (x1, y1)-(x2, y2), Color
  2028.         Line (-x1, y1)-(-x2, y2), Color
  2029.         Line (x1, -y1)-(x2, -y2), Color
  2030.         Line (-x1, -y1)-(-x2, -y2), Color
  2031.  
  2032.         'mirror diagonally
  2033.         xm1 = y1
  2034.         ym1 = x1
  2035.         xm2 = y2
  2036.         ym2 = x2
  2037.         Line (xm1, ym1)-(xm2, ym2), Color
  2038.         Line (-xm1, ym1)-(-xm2, ym2), Color
  2039.         Line (xm1, -ym1)-(xm2, -ym2), Color
  2040.         Line (-xm1, -ym1)-(-xm2, -ym2), Color
  2041.  
  2042.     Case 6: 'mirror around center point and diagonally
  2043.         'and then shift 45 degrees and repeat
  2044.         KaliedPlot 4, x1, y1, x2, y2, Color
  2045.  
  2046.         'shift 45 degrees, formula
  2047.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2048.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2049.         xm1 = x1 * Cos45 - y1 * Sin45
  2050.         ym1 = y1 * Cos45 + x1 * Sin45
  2051.         xm2 = x2 * Cos45 - y2 * Sin45
  2052.         ym2 = y2 * Cos45 + x2 * Sin45
  2053.  
  2054.         KaliedPlot 4, xm1, ym1, xm2, ym2, Color
  2055.  
  2056.     Case 7: 'mirror on x and y axis and diagonally
  2057.         'and then shift 45 degrees and repeat
  2058.         KaliedPlot 5, x1, y1, x2, y2, Color
  2059.  
  2060.         'shift 45 degrees, formula
  2061.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2062.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2063.         xm1 = x1 * Cos45 - y1 * Sin45
  2064.         ym1 = y1 * Cos45 + x1 * Sin45
  2065.         xm2 = x2 * Cos45 - y2 * Sin45
  2066.         ym2 = y2 * Cos45 + x2 * Sin45
  2067.  
  2068.         KaliedPlot 5, xm1, ym1, xm2, ym2, Color
  2069.  
  2070.     Case 8: 'mirror around center point and diagonally
  2071.         'and then shift 45 degrees and repeat
  2072.         'and then shift 22.5 and repeat the above
  2073.         KaliedPlot 6, x1, y1, x2, y2, Color
  2074.  
  2075.         'shift 22.5 degrees, formula
  2076.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2077.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2078.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  2079.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  2080.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  2081.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  2082.  
  2083.         KaliedPlot 6, xm1, ym1, xm2, ym2, Color
  2084.  
  2085.     Case 9: 'mirror on x and y axis and diagonally
  2086.         'and then shift 45 degrees and repeat
  2087.         'and then shift 22.5 and repeat the above
  2088.         KaliedPlot 7, x1, y1, x2, y2, Color
  2089.  
  2090.         'shift 22.5 degrees, formula
  2091.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2092.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2093.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  2094.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  2095.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  2096.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  2097.  
  2098.         KaliedPlot 7, xm1, ym1, xm2, ym2, Color
  2099.  
  2100.  
  2101.     Case 10: 'mirror around center point and diagonally
  2102.         'and then shift 45 degrees and repeat
  2103.         'and then shift 22.5 and repeat the above
  2104.         'and then shift 11.25 and repeat the above
  2105.         KaliedPlot 8, x1, y1, x2, y2, Color
  2106.  
  2107.         'shift 22.5 degrees, formula
  2108.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2109.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2110.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  2111.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  2112.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  2113.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  2114.  
  2115.         KaliedPlot 8, xm1, ym1, xm2, ym2, Color
  2116.  
  2117.     Case 11: 'mirror on x and y axis and diagonally
  2118.         'and then shift 45 degrees and repeat
  2119.         'and then shift 22.5 and repeat the above
  2120.         'and then shift 11.25 and repeat the above
  2121.         KaliedPlot 9, x1, y1, x2, y2, Color
  2122.  
  2123.         'shift 22.5 degrees, formula
  2124.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2125.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2126.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  2127.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  2128.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  2129.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  2130.  
  2131.         KaliedPlot 9, xm1, ym1, xm2, ym2, Color
  2132.  
  2133.     Case Else: MirrorMode = 1' if invalid value set, then change
  2134.     
  2135.     End Select
  2136.  
  2137.  
  2138. End Sub
  2139.  
  2140. Sub Lines ()
  2141.  
  2142.   ' have a random number of lines trace across the
  2143.   ' screen with multiple previous copies following
  2144.   ' them
  2145.  
  2146.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2147.   Dim il As Long, jl As Long, kl As Long
  2148.   Static Sets As Integer
  2149.   
  2150.   ' if first time then initialize
  2151.   If PlotInit = False Then
  2152.     
  2153.    'see if we need to reset changes made from previous init
  2154.    If PlotEnd = False Then
  2155.     
  2156.     'check if saver is permitted to run
  2157.     If CheckIfValidSaver(0) = 0 Then
  2158.       Exit Sub
  2159.     End If
  2160.     
  2161.     PlotInit = True
  2162.     Cls
  2163.     ForeColor = QBColor(15)
  2164.  
  2165.     'set number of sets between 1 and 4
  2166.     Sets = Rnd * 3 + 1
  2167.  
  2168.     'Set array size and clear the elements
  2169.     ReDim x1da(MaxLines, Sets) As Integer
  2170.     ReDim x2da(MaxLines, Sets) As Integer
  2171.     ReDim y1da(MaxLines, Sets) As Integer
  2172.     ReDim y2da(MaxLines, Sets) As Integer
  2173.     ReDim x1sa(Sets) As Single
  2174.     ReDim x2sa(Sets) As Single
  2175.     ReDim y1sa(Sets) As Single
  2176.     ReDim y2sa(Sets) As Single
  2177.     ReDim vx1sa(Sets) As Single
  2178.     ReDim vx2sa(Sets) As Single
  2179.     ReDim vy1sa(Sets) As Single
  2180.     ReDim vy2sa(Sets) As Single
  2181.     ReDim ax1sa(Sets) As Single
  2182.     ReDim ax2sa(Sets) As Single
  2183.     ReDim ay1sa(Sets) As Single
  2184.     ReDim ay2sa(Sets) As Single
  2185.     ReDim Colors(Sets) As Long
  2186.     
  2187.     Pointer = 1     ' start with array element 1
  2188.     
  2189.     ' set index to count number of times to repeat color
  2190.     '   to past maxvalue so that it will be recalculated
  2191.     RepeatIndex = MaxLines + 1
  2192.  
  2193.     For j = 1 To Sets
  2194.  
  2195.     'determine initial position of line
  2196.     x1sa(j) = Rnd * ScaleWidth
  2197.     x2sa(j) = Rnd * ScaleWidth
  2198.     y1sa(j) = Rnd * ScaleHeight
  2199.     y2sa(j) = Rnd * ScaleHeight
  2200.  
  2201.     Next j
  2202.     
  2203.     'find background color
  2204.     m = QBColor(0)
  2205.  
  2206.     'Calculate velocity limits
  2207.     MaxSpeedX = ScaleWidth * 15! / 800
  2208.     MaxSpeedY = ScaleWidth * 15! / 600
  2209.  
  2210.  
  2211.   Else 'reset changes done by previous init
  2212.  
  2213.     'Set array size and clear the elements
  2214.     ReDim x1da(0, 0) As Integer
  2215.     ReDim x2da(0, 0) As Integer
  2216.     ReDim y1da(0, 0) As Integer
  2217.     ReDim y2da(0, 0) As Integer
  2218.     ReDim x1sa(0) As Single
  2219.     ReDim x2sa(0) As Single
  2220.     ReDim y1sa(0) As Single
  2221.     ReDim y2sa(0) As Single
  2222.     ReDim vx1sa(0) As Single
  2223.     ReDim vx2sa(0) As Single
  2224.     ReDim vy1sa(0) As Single
  2225.     ReDim vy2sa(0) As Single
  2226.     ReDim ax1sa(0) As Single
  2227.     ReDim ax2sa(0) As Single
  2228.     ReDim ay1sa(0) As Single
  2229.     ReDim ay2sa(0) As Single
  2230.     ReDim Colors(0) As Long
  2231.  
  2232.     ClearScreen
  2233.     
  2234.   End If
  2235.  
  2236.   Else  ' put run code here
  2237.  
  2238.  
  2239.     ' check if time to get a new color
  2240.     If RepeatIndex > RepeatCount Then
  2241.     
  2242.     ' get colors
  2243.     For ii = 1 To Sets
  2244.       Colors(ii) = GetBrightNonGray()
  2245.     Next ii
  2246.  
  2247.     RepeatIndex = 1
  2248.     Else
  2249.     RepeatIndex = RepeatIndex + 1
  2250.     End If
  2251.  
  2252.     'Delete original Lines
  2253.     For j = 1 To Sets
  2254.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  2255.     Next j
  2256.  
  2257.     For j = 1 To Sets
  2258.  
  2259.         'Save New Lines
  2260.         x1da(Pointer, j) = x1sa(j)
  2261.         x2da(Pointer, j) = x2sa(j)
  2262.         y1da(Pointer, j) = y1sa(j)
  2263.         y2da(Pointer, j) = y2sa(j)
  2264.  
  2265.         'Draw new Line
  2266.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  2267.  
  2268.     Next j
  2269.  
  2270.     'Move pointer to next item
  2271.     Pointer = Pointer + 1
  2272.     If Pointer > MaxLines Then
  2273.         Pointer = 1
  2274.     End If
  2275.  
  2276.     For j = 1 To Sets
  2277.  
  2278.         'determine new acceleration
  2279.         ax1sa(j) = Rnd - .5
  2280.         ax2sa(j) = Rnd - .5
  2281.         ay1sa(j) = Rnd - .5
  2282.         ay2sa(j) = Rnd - .5
  2283.  
  2284.         'calculate new position
  2285.         x1sa(j) = x1sa(j) + vx1sa(j)
  2286.         x2sa(j) = x2sa(j) + vx2sa(j)
  2287.         y1sa(j) = y1sa(j) + vy1sa(j)
  2288.         y2sa(j) = y2sa(j) + vy2sa(j)
  2289.  
  2290.         'calculate new velocity
  2291.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2292.         vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  2293.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2294.         vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  2295.  
  2296.         'check if off screen
  2297.         If (x1sa(j) > ScaleWidth) Then
  2298.         'change direction
  2299.         vx1sa(j) = -Abs(vx1sa(j))
  2300.         ElseIf (x1sa(j) < 0) Then
  2301.         'change direction
  2302.         vx1sa(j) = Abs(vx1sa(j))
  2303.         End If
  2304.  
  2305.         If (y1sa(j) > ScaleHeight) Then
  2306.         'change direction
  2307.         vy1sa(j) = -Abs(vy1sa(j))
  2308.         ElseIf (y1sa(j) < 0) Then
  2309.         'change direction
  2310.         vy1sa(j) = Abs(vy1sa(j))
  2311.         End If
  2312.  
  2313.         If (x2sa(j) > ScaleWidth) Then
  2314.         'change direction
  2315.         vx2sa(j) = -Abs(vx2sa(j))
  2316.         ElseIf (x2sa(j) < 0) Then
  2317.         'change direction
  2318.         vx2sa(j) = Abs(vx2sa(j))
  2319.         End If
  2320.  
  2321.         If (y2sa(j) > ScaleHeight) Then
  2322.         'change direction
  2323.         vy2sa(j) = -Abs(vy2sa(j))
  2324.         ElseIf (y2sa(j) < 0) Then
  2325.         'change direction
  2326.         vy2sa(j) = Abs(vy2sa(j))
  2327.         End If
  2328.  
  2329.     Next j
  2330.     
  2331.     
  2332.   End If
  2333.  
  2334. End Sub
  2335.  
  2336. Function LoadSlide (File As String, ShowPic As Integer) As Integer
  2337.  'loads picture to screen, if gif file extension, then
  2338.  'save to dib bitmap, returns zero on failure
  2339.  
  2340.   Dim RetVal As Integer, i As Integer, l As Long
  2341.   Dim Header As Long, DataBits As Long
  2342.   Dim TempName As String
  2343.  
  2344.   RetVal = 1
  2345.  
  2346.   If InStr(UCase$(File), ".GIF") = 0 Then
  2347.  
  2348.     ' if not gif file, then bitmap
  2349.     If ShowPic Then
  2350.       On Error GoTo 116
  2351.       picture = LoadPicture(File)
  2352.       On Error GoTo 0
  2353.     End If
  2354.  
  2355.     'get dimensions of bitmap
  2356.     If GetSize(File) = 0 Then RetVal = 0
  2357.  
  2358.   Else ' convert gif to DIB
  2359.  
  2360.     l = ManyGifLoad(File, PicWidth, PicHeight)'load gif
  2361.     If l <= 0 Then
  2362.       LogFile "Could not read GIF file " + File, 1
  2363.       RetVal = 0
  2364.     Else
  2365.  
  2366.       'where to store converted file
  2367.       TempName = RTrim$(BitmapsDir) + "\tmprary.dib"
  2368.       i = ManyDIBWrite(TempName)
  2369.       If i <> 0 Then 'check for error
  2370.     LogFile "Could not write GIF file " + TempName, 1
  2371.     RetVal = 0
  2372.       Else
  2373.     If ShowPic Then
  2374.       On Error GoTo 116
  2375.       picture = LoadPicture(TempName)
  2376.       On Error GoTo 0
  2377.     End If
  2378.  
  2379.       End If
  2380.  
  2381.     End If
  2382.  
  2383.   End If
  2384.  
  2385.   LoadSlide = RetVal
  2386.   Exit Function
  2387.  
  2388. 116 'could not load file, out of memory?
  2389.   On Error GoTo 0
  2390.   RetVal = 0
  2391.   LogFile ("Could not load file " + File), 1
  2392.   Resume Next
  2393.  
  2394. End Function
  2395.  
  2396. Function LoadSlideAndTile (File As String) As Integer
  2397. ' returns zero on error
  2398.  
  2399.   Dim i As Integer, RetVal As Integer
  2400.  
  2401.   RetVal = 1
  2402.  
  2403.     If File = "" Then
  2404.       RetVal = 0
  2405.     Else
  2406.  
  2407.       i = LoadSlide(File, 1)'put file on display
  2408.  
  2409.       If i = 0 Then 'check if could not load
  2410.     RetVal = 0
  2411.       Else
  2412.     Replicate
  2413.       End If
  2414.     End If
  2415.  
  2416.   LoadSlideAndTile = i
  2417.  
  2418. End Function
  2419.  
  2420. Sub MultiSpiros ()
  2421.  
  2422.   'Do spirograph like figures
  2423.  
  2424.   'reserve memory
  2425.   Const Deg2Pi = PI / 180
  2426.   Static MaxRad As Integer'maximum radius for circles
  2427.   Const MaxNodes = 35'maximum number of nodes on spiro
  2428.   Dim Nodes As Integer
  2429.   Const MaxRpts = 7'max times to go around circle
  2430.   Dim Rpts As Integer
  2431.   Const PlotPoints = 1'number of points to plot each time
  2432.   Const ClearCount = 3'number on screen before clearing
  2433.   Static PlotAngleIncr As Single
  2434.   Static PlotEndAngle As Single
  2435.   Static PlotAngle As Single
  2436.   Static SinIncr As Single
  2437.   Static SinAngle As Single
  2438.   Static Xcenter As Integer
  2439.   Static Ycenter As Integer
  2440.   Static Xincr As Integer
  2441.   Static Yincr As Integer
  2442.   Const MaxSpiro = 8' maximum number of simultaneous spiros
  2443.   Static SpiroCnt As Integer
  2444.   Static Rad1 As Integer
  2445.   Static Rad2 As Integer
  2446.   Dim r As Single
  2447.   Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
  2448.   Dim il As Long, jl As Long, kl As Long
  2449.  
  2450.   ' if first time then initialize
  2451.   If PlotInit = False Then
  2452.     
  2453.     'see if we need to reset changes made from previous init
  2454.     If PlotEnd = False Then
  2455.     
  2456.     'check if saver is permitted to run
  2457.     If CheckIfValidSaver(0) = 0 Then
  2458.       Exit Sub
  2459.     End If
  2460.     
  2461.       PlotInit = True
  2462.       ForeColor = RGB(255, 255, 255)
  2463.       BackColor = RGB(0, 0, 0)
  2464.       Cls
  2465.  
  2466.      'initialize variables used
  2467.      PlotEndAngle = 0
  2468.      PlotAngle = 10
  2469.      MaxRad = ScaleHeight / 3'maximum radius for circles
  2470.      Pointer = 0
  2471.  
  2472.     Else 'reset changes done by previous init
  2473.  
  2474.       DrawWidth = 1' use narrow line
  2475.  
  2476.       ClearScreen
  2477.  
  2478.     End If
  2479.  
  2480.   Else  ' put run code here
  2481.  
  2482.    Do
  2483.  
  2484.     ' check if time to do new spiro
  2485.     If PlotAngle > PlotEndAngle Then
  2486.     
  2487.     'set foreground color
  2488.     ForeColor = GetBrightNonGray()
  2489.  
  2490.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  2491.     Rpts = Rnd * MaxRpts + .5
  2492.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  2493.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  2494.     Nodes = Rnd * MaxNodes + .5
  2495.     SinIncr = PlotAngleIncr * Nodes / Rpts
  2496.     SinAngle = 0
  2497.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  2498.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  2499.  
  2500.     'get location of first
  2501.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2502.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2503.  
  2504.     'get location of last
  2505.     i = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2506.     j = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2507.  
  2508.     'get number
  2509.     SpiroCnt = (MaxSpiro - 2) * Rnd + 2' maximum number of simultaneous spiros
  2510.  
  2511.     'calculate increment
  2512.     Xincr = (i - Xcenter) / (SpiroCnt - 1)
  2513.     Yincr = (j - Ycenter) / (SpiroCnt - 1)
  2514.  
  2515.     DrawWidth = 1 + 2 * Rnd ' set line width
  2516.  
  2517.     GoSub 3000 'calculate x1 and y1
  2518.  
  2519.     Delay 2'pause before clearing screen
  2520.     Cls
  2521.     
  2522.     End If
  2523.  
  2524.     For i = 1 To PlotPoints
  2525.  
  2526.       GoSub 3000 'calculate x1 and y1
  2527.  
  2528.       k = x1: l = y1: m = LastX: n = LastY
  2529.  
  2530.       'plot each spiro
  2531.       For j = 1 To SpiroCnt
  2532.  
  2533.     'draw line
  2534.     Line (m, n)-(k, l)
  2535.  
  2536.     'get location for next
  2537.     k = k + Xincr: l = l + Yincr
  2538.     m = m + Xincr: n = n + Yincr
  2539.  
  2540.       Next j
  2541.  
  2542.     Next i
  2543.     
  2544.     DoEvents
  2545.  
  2546.     CurrentTime = Timer
  2547.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  2548.  
  2549.    Loop
  2550.  
  2551.   End If
  2552.  
  2553.   Exit Sub
  2554.  
  2555. 3000 'calculate new point on screen
  2556.   LastX = x1: LastY = y1
  2557.   r = Rad1 + Rad2 * Sin(SinAngle)
  2558.   x1 = r * Cos(PlotAngle) + Xcenter
  2559.   y1 = r * Sin(PlotAngle) + Ycenter
  2560.   SinAngle = SinAngle + SinIncr
  2561.   PlotAngle = PlotAngle + PlotAngleIncr
  2562.  
  2563.   Return
  2564.  
  2565.  
  2566. End Sub
  2567.  
  2568. Sub NextSelection ()
  2569.  
  2570. Dim i As Integer
  2571. Dim Level As Single
  2572.  
  2573. If RandomFlag <> 0 Then
  2574.   ' pick a new selection but not the same as the last
  2575.   Do
  2576.     'i = Int(Rnd * MaxPlotType) + 1'choose next one at random
  2577.     Level = Rnd * TotalPriority' get random proportion of TP
  2578.  
  2579.     'now search array to see which saver this prop. falls into
  2580.     i = 1
  2581.     While (PriorityBreakPoints(i) <= Level)
  2582.       i = i + 1
  2583.     Wend
  2584.     'Debug.Print i, Level, TotalPriority
  2585.  
  2586.     If (i > MaxPlotType) Or (i < 1) Then i = PlotType'flag to try again
  2587.   Loop While (i = PlotType)
  2588.   PlotType = i
  2589.     
  2590. Else
  2591.   PlotType = PlotType + 1
  2592. End If
  2593.  
  2594. LogFile ("Next Saver is" + Str$(PlotType)), 1
  2595.  
  2596. End Sub
  2597.  
  2598. Sub Patch ()
  2599.  
  2600.   ' copy blocks of original screen to random spots
  2601.  
  2602.   ' if first time then initialize
  2603.   If PlotInit = False Then
  2604.     
  2605.    'see if we need to reset changes made from previous init
  2606.    If PlotEnd = False Then
  2607.     
  2608.     'check if saver is permitted to run
  2609.     If CheckIfValidSaver(1) = 0 Then
  2610.       Exit Sub
  2611.     End If
  2612.     
  2613.     ' set tick rate down
  2614.     Tick.Interval = 250
  2615.  
  2616.     ' start with original screen
  2617.     picture = original.Image
  2618.     
  2619.     PlotInit = True
  2620.  
  2621.     i = Int(Rnd * 2#) 'if i=0 then alternate reverse copy
  2622.  
  2623.   Else 'reset changes done by previous init
  2624.  
  2625.     ClearScreen
  2626.     
  2627.     'reset tick rate
  2628.     Tick.Interval = 50
  2629.  
  2630.   End If
  2631.  
  2632.   Else  ' put run code here
  2633.  
  2634.     BoxHeight = Rnd * ScaleHeight / 2.5
  2635.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  2636.  
  2637.     ' get random locations
  2638.     x1 = Rnd * ScaleWidth
  2639.     y1 = Rnd * ScaleHeight
  2640.     x2 = Rnd * ScaleWidth
  2641.     y2 = Rnd * ScaleHeight
  2642.  
  2643.     'make sure room in destination and source blocks
  2644.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  2645.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  2646.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  2647.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  2648.  
  2649.     'BitBlt Box from x2,y2 to x1,y1
  2650.     DC = original.hDC
  2651.     If i = 0 And Rnd < .5 Then
  2652.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &H330008 'not source copy
  2653.     Else
  2654.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020 'source copy
  2655.     End If
  2656.     
  2657.   End If
  2658.  
  2659. End Sub
  2660.  
  2661. Sub Polygons ()
  2662.  
  2663.   ' draw a randomly moving polygon on the screen
  2664.   ' with multiple previous copies following it
  2665.  
  2666.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2667.   Dim il As Long, jl As Long, kl As Long
  2668.   Static Sets As Integer
  2669.   
  2670.   ' if first time then initialize
  2671.   If PlotInit = False Then
  2672.     
  2673.     'see if we need to reset changes made from previous init
  2674.     If PlotEnd = False Then
  2675.     
  2676.     'check if saver is permitted to run
  2677.     If CheckIfValidSaver(0) = 0 Then
  2678.       Exit Sub
  2679.     End If
  2680.     
  2681.     PlotInit = True
  2682.     Cls
  2683.     ForeColor = QBColor(15)
  2684.  
  2685.     'set number of sets between 3 and 5
  2686.     Sets = Rnd * 2 + 3
  2687.  
  2688.     'Set array size and clear the elements
  2689.     ReDim x1da(MaxLines, Sets) As Integer
  2690.     ReDim y1da(MaxLines, Sets) As Integer
  2691.     ReDim x1sa(Sets) As Single
  2692.     ReDim y1sa(Sets) As Single
  2693.     ReDim vx1sa(Sets) As Single
  2694.     ReDim vy1sa(Sets) As Single
  2695.     ReDim ax1sa(Sets) As Single
  2696.     ReDim ay1sa(Sets) As Single
  2697.     
  2698.     Pointer = 1     ' start with array element 1
  2699.     
  2700.     ' set index to count number of times to repeat color
  2701.     '   to past maxvalue so that it will be recalculated
  2702.     RepeatIndex = MaxLines + 1
  2703.  
  2704.     For j = 1 To Sets
  2705.  
  2706.     'determine initial position of line
  2707.     x1sa(j) = Rnd * ScaleWidth
  2708.     y1sa(j) = Rnd * ScaleHeight
  2709.  
  2710.     Next j
  2711.     
  2712.     'find background color
  2713.     m = QBColor(0)
  2714.  
  2715.     'Calculate velocity limits
  2716.     MaxSpeedX = ScaleWidth * 15! / 800
  2717.     MaxSpeedY = ScaleWidth * 15! / 600
  2718.  
  2719.  
  2720.   Else 'reset changes done by previous init
  2721.  
  2722.     'Set array size and clear the elements
  2723.     ReDim x1da(0, 0) As Integer
  2724.     ReDim y1da(0, 0) As Integer
  2725.     ReDim x1sa(0) As Single
  2726.     ReDim y1sa(0) As Single
  2727.     ReDim vx1sa(0) As Single
  2728.     ReDim vy1sa(0) As Single
  2729.     ReDim ax1sa(0) As Single
  2730.     ReDim ay1sa(0) As Single
  2731.  
  2732.     ClearScreen
  2733.  
  2734.   End If
  2735.  
  2736.   Else  ' put run code here
  2737.  
  2738.  
  2739.     ' check if time to get a new color
  2740.     If RepeatIndex > RepeatCount Then
  2741.     
  2742.     ' get colors
  2743.     l = GetBrightNonGray()
  2744.     
  2745.     RepeatIndex = 1
  2746.     Else
  2747.     RepeatIndex = RepeatIndex + 1
  2748.     End If
  2749.  
  2750.     'Delete original Lines
  2751.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  2752.     For j = 3 To Sets
  2753.         Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  2754.     Next j
  2755.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  2756.  
  2757.     For j = 1 To Sets
  2758.  
  2759.         'Save New Lines
  2760.         x1da(Pointer, j) = x1sa(j)
  2761.         y1da(Pointer, j) = y1sa(j)
  2762.  
  2763.     Next j
  2764.  
  2765.     'Draw New Lines
  2766.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  2767.     For j = 3 To Sets
  2768.         Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  2769.     Next j
  2770.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  2771.  
  2772.  
  2773.     'Move pointer to next item
  2774.     Pointer = Pointer + 1
  2775.     If Pointer > MaxLines Then
  2776.         Pointer = 1
  2777.     End If
  2778.  
  2779.     For j = 1 To Sets
  2780.  
  2781.         'determine new acceleration
  2782.         ax1sa(j) = Rnd - .5
  2783.         ay1sa(j) = Rnd - .5
  2784.         
  2785.         'calculate new position
  2786.         x1sa(j) = x1sa(j) + vx1sa(j)
  2787.         y1sa(j) = y1sa(j) + vy1sa(j)
  2788.  
  2789.         'calculate new velocity
  2790.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2791.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2792.  
  2793.         'check if off screen
  2794.         If (x1sa(j) > ScaleWidth) Then
  2795.         'change direction
  2796.         vx1sa(j) = -Abs(vx1sa(j))
  2797.         ElseIf (x1sa(j) < 0) Then
  2798.         'change direction
  2799.         vx1sa(j) = Abs(vx1sa(j))
  2800.         End If
  2801.  
  2802.         If (y1sa(j) > ScaleHeight) Then
  2803.         'change direction
  2804.         vy1sa(j) = -Abs(vy1sa(j))
  2805.         ElseIf (y1sa(j) < 0) Then
  2806.         'change direction
  2807.         vy1sa(j) = Abs(vy1sa(j))
  2808.         End If
  2809.  
  2810.     Next j
  2811.     
  2812.     End If
  2813.  
  2814. End Sub
  2815.  
  2816. Sub Puzzle ()
  2817.  
  2818.   'scramble screen by shifting one column or row at a time
  2819.   
  2820.   Dim tempx As Integer, tempy As Integer
  2821.   Dim x As Integer, y As Integer
  2822.  
  2823.   ' if first time then initialize
  2824.   If PlotInit = False Then
  2825.     
  2826.     'see if we need to reset changes made from previous init
  2827.     If PlotEnd = False Then
  2828.     
  2829.     'check if saver is permitted to run
  2830.     If CheckIfValidSaver(1) = 0 Then
  2831.       Exit Sub
  2832.     End If
  2833.     
  2834.     ' set tick rate down
  2835.     Tick.Interval = 1000
  2836.  
  2837.     ' start with original screen
  2838.     picture = original.Image
  2839.     
  2840.     'find background color
  2841.     m = QBColor(0)
  2842.  
  2843.     PlotInit = True
  2844.  
  2845.     Number = Rnd * 16 + 4
  2846.     'Number = 20
  2847.  
  2848.     BoxHeight = ScaleHeight / Number
  2849.     BoxWidth = ScaleWidth / Number
  2850.  
  2851.     'initialize blocks
  2852.     ReDim x1da(Number, Number) As Integer
  2853.     ReDim y1da(Number, Number) As Integer
  2854.     For x1 = 1 To Number
  2855.     For y1 = 1 To Number
  2856.         x1da(x1, y1) = (x1 - 1) * BoxWidth
  2857.         y1da(x1, y1) = (y1 - 1) * BoxHeight
  2858.     Next y1
  2859.     Next x1
  2860.  
  2861.   Else 'reset changes done by previous init
  2862.  
  2863.     ReDim x1da(0, 0) As Integer
  2864.     ReDim y1da(0, 0) As Integer
  2865.  
  2866.     'reset tick rate
  2867.     Tick.Interval = 50
  2868.  
  2869.     ClearScreen
  2870.  
  2871.   End If
  2872.  
  2873.   Else  ' put run code here
  2874.  
  2875.     If Int(Rnd * 2) = 1 Then 'shift column
  2876.     x1 = Rnd * Number + 1: If x1 > Number Then x1 = 1
  2877.     If Int(Rnd * 2) = 1 Then 'shift down
  2878.         tempx = x1da(x1, Number)
  2879.         tempy = y1da(x1, Number)
  2880.         For y1 = Number To 2 Step -1
  2881.         x1da(x1, y1) = x1da(x1, y1 - 1)
  2882.         y1da(x1, y1) = y1da(x1, y1 - 1)
  2883.  
  2884.         'BitBlt Box to x1,y1
  2885.         DC = original.hDC
  2886.         x = (x1 - 1) * BoxWidth
  2887.         y = (y1 - 1) * BoxHeight
  2888.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2889.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2890.         Next y1
  2891.         y1 = 1
  2892.         x1da(x1, y1) = tempx
  2893.         y1da(x1, y1) = tempy
  2894.  
  2895.         'BitBlt Box to x1,y1
  2896.         DC = original.hDC
  2897.         x = (x1 - 1) * BoxWidth
  2898.         y = (y1 - 1) * BoxHeight
  2899.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2900.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2901.  
  2902.     Else ' shift up
  2903.  
  2904.         tempx = x1da(x1, 1)
  2905.         tempy = y1da(x1, 1)
  2906.         For y1 = 1 To (Number - 1)
  2907.         x1da(x1, y1) = x1da(x1, y1 + 1)
  2908.         y1da(x1, y1) = y1da(x1, y1 + 1)
  2909.  
  2910.         'BitBlt Box to x1,y1
  2911.         DC = original.hDC
  2912.         x = (x1 - 1) * BoxWidth
  2913.         y = (y1 - 1) * BoxHeight
  2914.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2915.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2916.         
  2917.         Next y1
  2918.         y1 = Number
  2919.         x1da(x1, y1) = tempx
  2920.         y1da(x1, y1) = tempy
  2921.  
  2922.         'BitBlt Box to x1,y1
  2923.         DC = original.hDC
  2924.         x = (x1 - 1) * BoxWidth
  2925.         y = (y1 - 1) * BoxHeight
  2926.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2927.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2928.  
  2929.     End If
  2930.  
  2931.     Else ' shift row
  2932.     
  2933.     y1 = Rnd * Number + 1: If y1 > Number Then y1 = 1
  2934.     If Int(Rnd * 2) = 1 Then 'shift right
  2935.         tempx = x1da(Number, y1)
  2936.         tempy = y1da(Number, y1)
  2937.         For x1 = Number To 2 Step -1
  2938.         x1da(x1, y1) = x1da(x1 - 1, y1)
  2939.         y1da(x1, y1) = y1da(x1 - 1, y1)
  2940.  
  2941.         'BitBlt Box to x1,y1
  2942.         DC = original.hDC
  2943.         x = (x1 - 1) * BoxWidth
  2944.         y = (y1 - 1) * BoxHeight
  2945.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2946.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2947.  
  2948.         Next x1
  2949.         x1 = 1
  2950.         x1da(x1, y1) = tempx
  2951.         y1da(x1, y1) = tempy
  2952.         
  2953.         'BitBlt Box to x1,y1
  2954.         DC = original.hDC
  2955.         x = (x1 - 1) * BoxWidth
  2956.         y = (y1 - 1) * BoxHeight
  2957.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2958.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2959.  
  2960.     Else 'shift left
  2961.  
  2962.         tempx = x1da(1, y1)
  2963.         tempy = y1da(1, y1)
  2964.         For x1 = 1 To (Number - 1)
  2965.         x1da(x1, y1) = x1da(x1 + 1, y1)
  2966.         y1da(x1, y1) = y1da(x1 + 1, y1)
  2967.  
  2968.         'BitBlt Box to x1,y1
  2969.         DC = original.hDC
  2970.         x = (x1 - 1) * BoxWidth
  2971.         y = (y1 - 1) * BoxHeight
  2972.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2973.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2974.  
  2975.         Next x1
  2976.         x1 = Number
  2977.         x1da(x1, y1) = tempx
  2978.         y1da(x1, y1) = tempy
  2979.         
  2980.         'BitBlt Box to x1,y1
  2981.         DC = original.hDC
  2982.         x = (x1 - 1) * BoxWidth
  2983.         y = (y1 - 1) * BoxHeight
  2984.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2985.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2986.  
  2987.     End If
  2988.  
  2989.     End If
  2990.  
  2991.   End If
  2992.  
  2993.  
  2994. End Sub
  2995.  
  2996. Sub ReadPriorities ()
  2997.     
  2998.   Dim i As Integer, j As Integer
  2999.   Dim temp As String * 30, Out  As String
  3000.   Dim Priority As Single
  3001.   ReDim PriorityBreakPoints(MaxPlotType + 1) As Single
  3002.   ReDim Priorities(MaxPlotType) As Integer
  3003.   TotalPriority = 0
  3004.  
  3005.   For i = 1 To MaxPlotType
  3006.     j = GetPrivateProfileString(secName, PriorityBaseName + Int2Str(i), "1", temp, 28, iniName)
  3007.     Priority = Val(temp)
  3008.  
  3009.     Out = Out + Str$(Priority)
  3010.  
  3011.     If Priority < 0# Then Priority = 0#
  3012.  
  3013.     If Priority = 0# Then
  3014.       Priorities(i) = 0
  3015.     Else
  3016.       Priorities(i) = 1
  3017.     End If
  3018.     
  3019.     TotalPriority = TotalPriority + Priority
  3020.     PriorityBreakPoints(i) = TotalPriority
  3021.   Next
  3022.  
  3023.   LogFile "Priorites set to " + Out, 0
  3024.  
  3025.   PriorityBreakPoints(MaxPlotType + 1) = TotalPriority + 3.402E+38
  3026.  
  3027. End Sub
  3028.  
  3029. Sub Replicate ()
  3030.  
  3031.   Dim x As Integer, y As Integer, x1 As Integer, y1 As Integer
  3032.  
  3033.   DoEvents
  3034.  
  3035.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  3036.  
  3037.   'limit sizes
  3038.   If PicWidth > ScrnWidth Then PicWidth = ScrnWidth
  3039.   If PicHeight > ScrnHeight Then PicHeight = ScrnHeight
  3040.  
  3041.   If (PicWidth < ScrnWidth) Or (PicHeight < ScrnHeight) Then
  3042.  
  3043.     'need to center picture
  3044.  
  3045.     'first backup picture
  3046.     BitBlt original.hDC, 0, 0, PicWidth, PicHeight, DC, 0, 0, &HCC0020
  3047.  
  3048.     'clear original
  3049.     'Picture = LoadPicture()
  3050.  
  3051.     ' now copy back centered
  3052.     x = ScrnWidth / 2 - PicWidth / 2
  3053.     y = ScrnHeight / 2 - PicHeight / 2
  3054.     BitBlt hDC, x, y, PicWidth, PicHeight, original.hDC, 0, 0, &HCC0020
  3055.  
  3056.  
  3057.   End If
  3058.  
  3059.   If (PicWidth < ScrnWidth) Then 'fill row
  3060.  
  3061.     '1st copy left
  3062.     x1 = x
  3063.     While x1 > 0
  3064.       BitBlt hDC, x1 - PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  3065.       x1 = x1 - PicWidth
  3066.     Wend
  3067.   
  3068.     'next copy right
  3069.     x1 = x
  3070.     While x1 < ScrnWidth
  3071.       BitBlt hDC, x1 + PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  3072.       x1 = x1 + PicWidth
  3073.     Wend
  3074.  
  3075.   End If
  3076.   
  3077.   If (PicHeight < ScrnHeight) Then
  3078.  
  3079.     '1st copy up
  3080.     y1 = y
  3081.     While y1 > 0
  3082.       BitBlt hDC, 0, y1 - PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  3083.       y1 = y1 - PicHeight
  3084.     Wend
  3085.   
  3086.     'next copy down
  3087.     y1 = y
  3088.     While y1 < ScrnHeight
  3089.       BitBlt hDC, 0, y1 + PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  3090.       y1 = y1 + PicHeight
  3091.     Wend
  3092.  
  3093.   End If
  3094.  
  3095.   i = DeleteDC(DC)
  3096.  
  3097. End Sub
  3098.  
  3099. Sub Roll ()
  3100.  
  3101.   ' the display rolls both horizontally and vertically
  3102.  
  3103.   Dim v As Integer
  3104.  
  3105.   ' if first time then initialize
  3106.   If PlotInit = False Then
  3107.     
  3108.     'see if we need to reset changes made from previous init
  3109.     If PlotEnd = False Then
  3110.     
  3111.     'check if saver is permitted to run
  3112.     If CheckIfValidSaver(1) = 0 Then
  3113.       Exit Sub
  3114.     End If
  3115.     
  3116.     ' start with original screen
  3117.     picture = original.Image
  3118.  
  3119.     PlotInit = True
  3120.  
  3121.     'Calculate velocity limits
  3122.     MaxSpeedX = ScaleWidth * 15! / 800
  3123.     MaxSpeedY = ScaleWidth * 15! / 600
  3124.  
  3125.     ' initial velocities
  3126.     vy1 = 0: vx1 = 0
  3127.  
  3128.     ' initial offset
  3129.     x1 = 0: y1 = 0
  3130.  
  3131.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  3132.  
  3133.   Else 'reset changes done by previous init
  3134.  
  3135.     ClearScreen
  3136.  
  3137.   End If
  3138.  
  3139.   Else  ' put run code here
  3140.  
  3141.     DC = original.hDC
  3142.  
  3143.     If Direction Then
  3144.     ' do vertical scroll
  3145.     BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  3146.     BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  3147.     Else
  3148.     ' do horizontal scroll
  3149.     BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  3150.     BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  3151.     End If
  3152.  
  3153.     'determine new acceleration
  3154.     ax1 = Rnd - .5
  3155.     ay1 = Rnd - .5
  3156.         
  3157.     'calculate new velocity
  3158.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3159.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3160.  
  3161.     'find new roll amount
  3162.     x1 = x1 + vx1
  3163.     If x1 > ScaleWidth Then
  3164.     x1 = x1 - ScaleWidth
  3165.     Else
  3166.     If x1 < 0 Then
  3167.         x1 = x1 + ScaleWidth
  3168.     End If
  3169.     End If
  3170.         
  3171.     y1 = y1 + vy1
  3172.     If y1 > ScaleHeight Then
  3173.     y1 = y1 - ScaleHeight
  3174.     Else
  3175.     If y1 < 0 Then
  3176.         y1 = y1 + ScaleHeight
  3177.     End If
  3178.     End If
  3179.         
  3180.   End If
  3181.  
  3182. End Sub
  3183.  
  3184. Sub RunSelection ()
  3185.  
  3186.     ' execute the appropriate selection
  3187.  
  3188.     Select Case PlotType
  3189.  
  3190.     Case 1: Squiggles
  3191.     Case 2: Kalied2
  3192.     Case 3: Polygons
  3193.     Case 4: Circles
  3194.     Case 5: Kalied
  3195.     Case 6: Lines
  3196.     Case 7: Roll
  3197.     Case 8: FilledCircles
  3198.     Case 9: Patch
  3199.     Case 10: Spiro
  3200.     Case 11: Scrape
  3201.     Case 12: Stretch
  3202.     Case 13: Dribble
  3203.     Case 14: Drop
  3204.     Case 15: Slides
  3205.     Case 16: FilledPolygons
  3206.     Case 17: MultiSpiros
  3207.     Case 18: Puzzle
  3208.     Case 19: ShootHoles
  3209.     Case 20: CyclePalette
  3210.     Case 21: Confetti
  3211.     Case Else: PlotType = 1
  3212.            RunSelection ' try again
  3213.  
  3214.     End Select
  3215.  
  3216. End Sub
  3217.  
  3218. Sub Scrape ()
  3219.  
  3220.   Static smear As Integer
  3221.  
  3222.   ' bitblt's with various patterns, dragging them
  3223.   ' across the screen randomly
  3224.  
  3225.   ' if first time then initialize
  3226.   If PlotInit = False Then
  3227.     
  3228.     'see if we need to reset changes made from previous init
  3229.     If PlotEnd = False Then
  3230.     
  3231.     'check if saver is permitted to run
  3232.     If CheckIfValidSaver(1) = 0 Then
  3233.       Exit Sub
  3234.     End If
  3235.     
  3236.     ' start with original screen
  3237.     picture = original.Image
  3238.     
  3239.     PlotInit = True
  3240.  
  3241.     'determine initial position of line
  3242.     x1 = Rnd * ScaleWidth
  3243.     y1 = Rnd * ScaleHeight
  3244.     
  3245.     'Calculate velocity limits
  3246.     MaxSpeedX = ScaleWidth * 15! / 800
  3247.     MaxSpeedY = ScaleWidth * 15! / 600
  3248.  
  3249.     BoxHeight = 400 * Rnd ^ 3 + 20
  3250.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  3251.  
  3252.     ' zero initial velocity
  3253.     vx1 = 0: vy1 = 0
  3254.  
  3255.     'default for smear
  3256.     smear = False
  3257.  
  3258.     ' choose scrape type at random
  3259.     i = Rnd * 14 + 1
  3260.     'i = 12
  3261.     Select Case i
  3262.  
  3263.     Case 1: Pattern = &H42 'Black Out
  3264.         Locked = True
  3265.     Case 2: Pattern = &HFF0062 'White Out
  3266.         Locked = True
  3267.     Case 3: Pattern = &HBB0226 'MergePaint
  3268.         Locked = False
  3269.     Case 4: Pattern = &H330008 'Not source copy
  3270.         Locked = True
  3271.     Case 5: Pattern = &H330008 'Not source copy
  3272.         Locked = False
  3273.     Case 6: Pattern = &H330008 'Not source copy
  3274.         Locked = False
  3275.         picture = LoadPicture() ' start with blank screen
  3276.     Case 7: Pattern = &H330008 'Not source copy
  3277.         smear = True
  3278.         'set random source location
  3279.         x2 = Rnd * (ScaleWidth - BoxWidth)
  3280.         y2 = Rnd * (ScaleHeight - BoxHeight)
  3281.     Case 8: Pattern = &H660046 'source invert
  3282.         Locked = True
  3283.     Case 9: Pattern = &H8800C6 'source and
  3284.         Locked = False
  3285.     Case 10: Pattern = &HEE0086 'source paint (or)
  3286.         Locked = False
  3287.     Case 11: Pattern = &H550009 'Invert Destination
  3288.         Locked = True
  3289.     Case 12: Pattern = &HCC0020 'Source Copy
  3290.         Locked = False
  3291.     Case 13: Pattern = &HCC0020 'Source Copy
  3292.         Locked = True
  3293.         picture = LoadPicture() ' start with blank screen
  3294.     Case Else: Pattern = &HCC0020 'Source Copy
  3295.         smear = True
  3296.         'set random source location
  3297.         x2 = Rnd * (ScaleWidth - BoxWidth)
  3298.         y2 = Rnd * (ScaleHeight - BoxHeight)
  3299.  
  3300.     End Select
  3301.     
  3302.   Else 'reset changes done by previous init
  3303.  
  3304.     ClearScreen
  3305.  
  3306.   End If
  3307.  
  3308.   Else  ' put run code here
  3309.  
  3310.     If smear Then
  3311.       'do nothing
  3312.     
  3313.     ' do locking if necessary
  3314.     ElseIf Locked Then
  3315.         x2 = x1: y2 = y1
  3316.     Else 'do offset
  3317.         x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  3318.         y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  3319.     End If
  3320.  
  3321.     'BitBlt Box at x1,y1
  3322.     DC = original.hDC
  3323.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  3324.     
  3325.     'determine new acceleration
  3326.     ax1 = Rnd - .5
  3327.     ay1 = Rnd - .5
  3328.         
  3329.     'calculate new position
  3330.     x1 = x1 + vx1
  3331.     y1 = y1 + vy1
  3332.         
  3333.     'calculate new velocity
  3334.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3335.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3336.         
  3337.     'check if off screen
  3338.     If (x1 > ScaleWidth - BoxWidth) Then
  3339.         'change direction
  3340.         vx1 = -Abs(vx1)
  3341.     ElseIf (x1 < 0) Then
  3342.         'change direction
  3343.         vx1 = Abs(vx1)
  3344.     End If
  3345.  
  3346.     If (y1 > ScaleHeight - BoxHeight) Then
  3347.         'change direction
  3348.         vy1 = -Abs(vy1)
  3349.     ElseIf (y1 < 0) Then
  3350.         'change direction
  3351.         vy1 = Abs(vy1)
  3352.     End If
  3353.  
  3354.     
  3355.     
  3356.   End If
  3357.  
  3358.  
  3359. End Sub
  3360.  
  3361. Sub SetWindow2DIBPalette (State As Integer)
  3362.   
  3363.   Dim i As Integer, j As Integer, k As Integer, l As Integer
  3364.   Dim usepal%
  3365.  
  3366.   'read dib palette into logical palette for cycling
  3367.   ManyLoadLogPal Pal, 0, 256, State
  3368.  
  3369.   usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  3370.    
  3371.   'this has problems:
  3372.   'i = SetPaletteEntries%(usepal%, 0, PALENTRIES, Pal.palPalEntry(0))
  3373.  
  3374.   'Pal.palNumEntries
  3375.  
  3376.   'try to set windows palette to logical palette using clipboard
  3377.   If PaletteHandle <> 0 Then
  3378.     i = DeleteObject(PaletteHandle)
  3379.   End If
  3380.   PaletteHandle = CreatePalette(Pal)
  3381.   j = OpenClipboard(hWnd)
  3382.   k = SetClipboardData(CF_PALETTE, PaletteHandle)
  3383.   l = CloseClipboard()
  3384.   picture = Clipboard.GetData(CF_PALETTE)
  3385.   Clipboard.Clear
  3386.  
  3387. End Sub
  3388.  
  3389. Sub ShootHoles ()
  3390.  
  3391.   ' shoots small holes approximately at the same place
  3392.  
  3393.   Dim i As Integer, j As Integer, k As Integer
  3394.   Dim r As Long, x As Long, y As Long
  3395.   Static Radius As Integer, HoleSize  As Integer
  3396.   Dim temp As Single
  3397.   Const pi2 = PI * 2
  3398.  
  3399.   ' if first time then initialize
  3400.   If PlotInit = False Then
  3401.     
  3402.     'see if we need to reset changes made from previous init
  3403.     If PlotEnd = False Then
  3404.     
  3405.     'check if saver is permitted to run
  3406.     If CheckIfValidSaver(1) = 0 Then
  3407.       Exit Sub
  3408.     End If
  3409.     
  3410.     ' start with original screen
  3411.     picture = original.Image
  3412.     
  3413.     PlotInit = True
  3414.  
  3415.     'determine initial position of shot
  3416.     x1 = Rnd * ScaleWidth
  3417.     y1 = Rnd * ScaleHeight
  3418.  
  3419.     'determine maximum radius of shot
  3420.     Radius = (ScaleHeight - 100) * Rnd + 100
  3421.  
  3422.     'set size of holes
  3423.     HoleSize = 20 * Rnd ^ 2 + 2
  3424.  
  3425.  
  3426.     RunMode = Int(Rnd * 3)'choose color mode to show
  3427.  
  3428.     FillStyle = 0 'solid fill
  3429.  
  3430.     If RunMode > 0 Then ' if random color then use larger spots
  3431.     i = Rnd * 255: If i > 255 Then i = 255
  3432.     j = Rnd * 255: If j > 255 Then j = 255
  3433.     k = Rnd * 255: If k > 255 Then k = 255
  3434.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  3435.     FillColor = ForeColor
  3436.     Else
  3437.  
  3438.       ForeColor = RGB(0, 0, 0)' use black box
  3439.       FillColor = RGB(0, 0, 0) 'set black fill
  3440.  
  3441.     End If
  3442.  
  3443.   Else 'reset changes done by previous init
  3444.  
  3445.     ClearScreen
  3446.     FillStyle = 1 'transparent fill
  3447.  
  3448.   End If
  3449.  
  3450. Else  ' put run code here
  3451.  
  3452.     If RunMode > 1 Then ' if random color then use larger spots
  3453.     i = Rnd * 255: If i > 255 Then i = 255
  3454.     j = Rnd * 255: If j > 255 Then j = 255
  3455.     k = Rnd * 255: If k > 255 Then k = 255
  3456.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  3457.     FillColor = ForeColor
  3458.     End If
  3459.  
  3460.     'get distance from center
  3461.     r = Rnd * Radius
  3462.  
  3463.     'get random angle
  3464.     temp = Rnd * pi2
  3465.  
  3466.     'get x portion
  3467.     x = r * Cos(temp)
  3468.  
  3469.     'get y portion
  3470.     y = r * Sin(temp)
  3471.  
  3472.     ' randomly change sign of x offset
  3473.     If Rnd > .5 Then
  3474.       x = -x
  3475.     End If
  3476.  
  3477.     ' randomly change sign of y offset
  3478.     If Rnd > .5 Then
  3479.       y = -y
  3480.     End If
  3481.  
  3482.     ' put random hole here
  3483.     Circle (x1 + x, y1 + y), HoleSize, , , , 1
  3484.  
  3485.   End If
  3486.  
  3487.  
  3488. End Sub
  3489.  
  3490. Sub ShowPal (palette As LOGPALETTE)
  3491. 'displays the current palette
  3492.  
  3493.     Dim usepal%
  3494.  
  3495.     ' Get a handle to the control's palette
  3496.     usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  3497.    
  3498.     AnimatePalette usepal%, 0, PALENTRIES, palette.palPalEntry(0)
  3499.  
  3500. End Sub
  3501.  
  3502. Sub Slides ()
  3503.  
  3504.   'cycle between different bitmaps
  3505.  
  3506.   Dim j As Integer
  3507.   Static File As String
  3508.   Static OldTime As Long
  3509.   Static running As Integer
  3510.   Dim CurTime As Long
  3511.   Dim FileName As String
  3512.  
  3513.   ' if first time then initialize
  3514.   If PlotInit = False Then
  3515.     
  3516.    'see if we need to reset changes made from previous init
  3517.    If PlotEnd = False Then
  3518.     
  3519.     'check if saver is permitted to run
  3520.     If CheckIfValidSaver(1) = 0 Then
  3521.       Exit Sub
  3522.     End If
  3523.     
  3524.     File = GetNextFile(BitmapsDir, 1, "gif", "bmp", "")
  3525.  
  3526.     ' find file
  3527.     j = Rnd * 50 ' pick file at random
  3528.     For i = 1 To j
  3529.  
  3530.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  3531.  
  3532.     Next i
  3533.  
  3534.     i = LoadSlideAndTile(File)
  3535.     If i = 0 Then 'check if could not load
  3536.       NextSelection 'jump to next since there are no bitmap files in directory
  3537.       Exit Sub
  3538.     End If
  3539.  
  3540.     OldTime = Timer
  3541.  
  3542.     running = False
  3543.  
  3544.     PlotInit = True
  3545.  
  3546.  
  3547.   Else 'reset changes done by previous init
  3548.  
  3549.     ' save screen in place of original for latter use
  3550.     ' we do this because on palette based systems
  3551.     ' the slide procedure messes up the color
  3552.     ' palette and the Clipboard.setData 9 and
  3553.     ' Clipboard.GetData(9) sequence does not restore
  3554.     ' it, so we just use the new picture with the
  3555.     ' new palette from now on
  3556.     DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  3557.     BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  3558.     i = DeleteDC(DC)
  3559.  
  3560.     i = ManyDibFree() 'free memory used for dib
  3561.     If i <> 0 Then
  3562.       LogFile "Could not free memory", 1
  3563.     End If
  3564.  
  3565.     ClearScreen
  3566.  
  3567.   End If
  3568.  
  3569. Else  ' put run code here
  3570.  
  3571.     If running Then Exit Sub ' no recursive calls
  3572.  
  3573.     If File = "" Then Exit Sub
  3574.  
  3575.     CurTime = Timer
  3576.     If (CurTime >= OldTime) And ((OldTime + BmpSeconds) > CurTime) Then Exit Sub
  3577.  
  3578.     OldTime = Timer
  3579.  
  3580.     running = True
  3581.  
  3582.     j = Rnd * 20
  3583.  
  3584.     For i = 1 To j
  3585.  
  3586.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  3587.  
  3588.     Next i
  3589.  
  3590.     i = LoadSlideAndTile(File)
  3591.     If i = 0 Then 'check if could not load
  3592.       NextSelection 'jump to next since there are no bitmap files in directory
  3593.       Exit Sub
  3594.     End If
  3595.  
  3596.   End If
  3597.  
  3598.   running = False
  3599.  
  3600.   Exit Sub
  3601.  
  3602. 115 'directory path does not exist
  3603.   On Error GoTo 0
  3604.   LogFile ("Could not find file " + FileName), 1
  3605.   Resume 117
  3606.  
  3607. 117 NextSelection 'jump to next since there are no bitmap files in directory
  3608.   Exit Sub
  3609.  
  3610. End Sub
  3611.  
  3612. Sub Spiro ()
  3613.  
  3614.   'Do spirograph like figures
  3615.  
  3616.   'reserve memory
  3617.   Const Deg2Pi = PI / 180
  3618.   Static MaxRad As Integer'maximum radius for circles
  3619.   Const MaxNodes = 35'maximum number of nodes on spiro
  3620.   Dim Nodes As Integer
  3621.   Const MaxRpts = 7'max times to go around circle
  3622.   Dim Rpts As Integer
  3623.   Const PlotPoints = 1'number of points to plot each time
  3624.   Const ClearCount = 3'number on screen before clearing
  3625.   Static PlotAngleIncr As Single
  3626.   Static PlotEndAngle As Single
  3627.   Static PlotAngle As Single
  3628.   Static SinIncr As Single
  3629.   Static SinAngle As Single
  3630.   Static Xcenter As Integer
  3631.   Static Ycenter As Integer
  3632.   Static Rad1 As Integer
  3633.   Static Rad2 As Integer
  3634.   Dim r As Single
  3635.   Dim l As Integer
  3636.  
  3637.   ' if first time then initialize
  3638.   If PlotInit = False Then
  3639.     
  3640.    'see if we need to reset changes made from previous init
  3641.    If PlotEnd = False Then
  3642.     
  3643.     'check if saver is permitted to run
  3644.     If CheckIfValidSaver(0) = 0 Then
  3645.       Exit Sub
  3646.     End If
  3647.     
  3648.       PlotInit = True
  3649.       ForeColor = RGB(255, 255, 255)
  3650.       BackColor = RGB(0, 0, 0)
  3651.       Cls
  3652.  
  3653.      'initialize variables used
  3654.      PlotEndAngle = 0
  3655.      PlotAngle = 10
  3656.      MaxRad = ScaleHeight / 3'maximum radius for circles
  3657.      Pointer = 0
  3658.  
  3659.     Else 'reset changes done by previous init
  3660.  
  3661.       DrawWidth = 1' use narrow line
  3662.  
  3663.       ClearScreen
  3664.  
  3665.     End If
  3666.  
  3667.   Else  ' put run code here
  3668.  
  3669.    Do
  3670.  
  3671.     ' check if time to do new spiro
  3672.     If PlotAngle > PlotEndAngle Then
  3673.     
  3674.     'set foreground color
  3675.     ForeColor = GetBrightNonGray()
  3676.  
  3677.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  3678.     Rpts = Rnd * MaxRpts + .5
  3679.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  3680.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  3681.     Nodes = Rnd * MaxNodes + .5
  3682.     SinIncr = PlotAngleIncr * Nodes / Rpts
  3683.     SinAngle = 0
  3684.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  3685.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  3686.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  3687.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  3688.  
  3689.     DrawWidth = 1 + 2 * Rnd' use narrow line
  3690.  
  3691.     GoSub 2000 'calculate x1 and y1
  3692.  
  3693.     Pointer = Pointer + 1
  3694.     If Pointer >= ClearCount Then
  3695.       Delay 3'pause before clearing screen
  3696.       Cls
  3697.       Pointer = 0
  3698.     End If
  3699.     
  3700.     currentx = x1
  3701.     currenty = y1
  3702.  
  3703.     End If
  3704.  
  3705.     For l = 1 To PlotPoints
  3706.  
  3707.       GoSub 2000 'calculate x1 and y1
  3708.     
  3709.       'draw line
  3710.       'Line (LastX, LastY)-(x1, y1)
  3711.       Line -(x1, y1)
  3712.  
  3713.     Next l
  3714.     
  3715.     DoEvents
  3716.  
  3717.     CurrentTime = Timer
  3718.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  3719.  
  3720.    Loop
  3721.  
  3722.   End If
  3723.  
  3724.   Exit Sub
  3725.  
  3726. 2000 'calculate new point on screen
  3727.   'LastX = x1: LastY = y1
  3728.   r = Rad1 + Rad2 * Sin(SinAngle)
  3729.   x1 = r * Cos(PlotAngle) + Xcenter
  3730.   y1 = r * Sin(PlotAngle) + Ycenter
  3731.   SinAngle = SinAngle + SinIncr
  3732.   PlotAngle = PlotAngle + PlotAngleIncr
  3733.  
  3734.   Return
  3735.  
  3736. End Sub
  3737.  
  3738. Sub Squiggles ()
  3739.  
  3740.   ' draw multiple squiggles on the screen.
  3741.   ' each squiggle is assign a random color at the
  3742.   ' start, then the head travels randomly and the
  3743.   ' tail is erased
  3744.  
  3745.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  3746.   Dim il As Long, jl As Long, kl As Long
  3747.   Static SquigNumb As Integer
  3748.   Static SquigLen As Integer
  3749.   Static EndPointer As Integer, StartPointer As Integer
  3750.  
  3751.   ' if first time then initialize
  3752.   If PlotInit = False Then
  3753.     
  3754.    'see if we need to reset changes made from previous init
  3755.    If PlotEnd = False Then
  3756.     
  3757.     'check if saver is permitted to run
  3758.     If CheckIfValidSaver(0) = 0 Then
  3759.       Exit Sub
  3760.     End If
  3761.     
  3762.     PlotInit = True
  3763.     Cls
  3764.     ForeColor = QBColor(15)
  3765.  
  3766.     SquigNumb = Rnd * 10 + 10
  3767.     SquigLen = Rnd * 100 + 50
  3768.  
  3769.     'Allocate Memory
  3770.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  3771.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  3772.     ReDim x1sa(SquigNumb) As Single
  3773.     ReDim y1sa(SquigNumb) As Single
  3774.     ReDim vx1sa(SquigNumb) As Single
  3775.     ReDim vy1sa(SquigNumb) As Single
  3776.     ReDim ax1sa(SquigNumb) As Single
  3777.     ReDim ay1sa(SquigNumb) As Single
  3778.     ReDim Colors(SquigNumb) As Long
  3779.     
  3780.     Pointer = 1
  3781.  
  3782.     'Print "Clearing Array"
  3783.     For j = 1 To SquigNumb
  3784.     'determine initial position of line
  3785.     x1sa(j) = Rnd * ScaleWidth
  3786.     y1sa(j) = Rnd * ScaleHeight
  3787.  
  3788.     For i = 1 To SquigLen
  3789.         x1da(i, j) = x1sa(j)
  3790.         y1da(i, j) = y1sa(j)
  3791.     Next i
  3792.  
  3793.     Next j
  3794.     
  3795.     'find background color
  3796.     m = QBColor(0)
  3797.  
  3798.     ' get colors
  3799.     For ii = 1 To SquigNumb
  3800.     Colors(ii) = GetBrightNonGray()
  3801.     Next ii
  3802.  
  3803.     'Calculate velocity limits
  3804.     MaxSpeedX = ScaleWidth * 15! / 800
  3805.     MaxSpeedY = ScaleWidth * 15! / 600
  3806.  
  3807.   Else 'reset changes done by previous init
  3808.  
  3809.     ReDim x1da(0, 0)  As Integer
  3810.     ReDim y1da(0, 0)  As Integer
  3811.     ReDim x1sa(0) As Single
  3812.     ReDim y1sa(0) As Single
  3813.     ReDim vx1sa(0) As Single
  3814.     ReDim vy1sa(0) As Single
  3815.     ReDim ax1sa(0) As Single
  3816.     ReDim ay1sa(0) As Single
  3817.     ReDim Colors(0) As Long
  3818.  
  3819.     ClearScreen
  3820.  
  3821.   End If
  3822.  
  3823.   Else  ' put run code here
  3824.   
  3825.  
  3826.     'find where tail line went to
  3827.     If Pointer < SquigLen Then
  3828.         EndPointer = Pointer + 1
  3829.     Else
  3830.         EndPointer = 1
  3831.     End If
  3832.  
  3833.     'find where new line goes
  3834.     If Pointer > 1 Then
  3835.         StartPointer = Pointer - 1
  3836.     Else
  3837.         StartPointer = SquigLen
  3838.     End If
  3839.  
  3840.     If Rnd < .1 Then 'change a color 10% of the time
  3841.     
  3842.       ii = Int(Rnd * SquigNumb + 1)' get random squiggle to change
  3843.       If ii > SquigNumb Then ii = 1
  3844.       Colors(ii) = GetBrightNonGray()
  3845.  
  3846.     End If
  3847.  
  3848.     For j = 1 To SquigNumb
  3849.     
  3850.         'Erase tails of squigles
  3851.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  3852.  
  3853.         'Save new points
  3854.         x1da(Pointer, j) = x1sa(j)
  3855.         y1da(Pointer, j) = y1sa(j)
  3856.  
  3857.         'Draw front of Squigles
  3858.         Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  3859.  
  3860.     Next j
  3861.  
  3862.     'Move pointer to next item
  3863.     Pointer = Pointer + 1
  3864.     If Pointer > SquigLen Then
  3865.         Pointer = 1
  3866.     End If
  3867.  
  3868.     For j = 1 To SquigNumb
  3869.  
  3870.         'determine new acceleration
  3871.         ax1sa(j) = Rnd * 4 - 2
  3872.         ay1sa(j) = Rnd * 4 - 2
  3873.  
  3874.         'calculate new position
  3875.         x1sa(j) = x1sa(j) + vx1sa(j)
  3876.         y1sa(j) = y1sa(j) + vy1sa(j)
  3877.  
  3878.         'calculate new velocity
  3879.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  3880.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  3881.  
  3882.         'check if off screen
  3883.         If (x1sa(j) > ScaleWidth) Then
  3884.         x1sa(j) = ScaleWidth
  3885.         'change direction
  3886.         vx1sa(j) = -Abs(vx1sa(j))
  3887.         ElseIf (x1sa(j) < 0) Then
  3888.         x1sa(j) = 0
  3889.         'change direction
  3890.         vx1sa(j) = Abs(vx1sa(j))
  3891.         End If
  3892.  
  3893.         If (y1sa(j) > ScaleHeight) Then
  3894.         y1sa(j) = ScaleHeight
  3895.         'change direction
  3896.         vy1sa(j) = -Abs(vy1sa(j))
  3897.         ElseIf (y1sa(j) < 0) Then
  3898.         y1sa(j) = 0
  3899.         'change direction
  3900.         vy1sa(j) = Abs(vy1sa(j))
  3901.         End If
  3902.  
  3903.     Next j
  3904.     
  3905.   End If
  3906.  
  3907. End Sub
  3908.  
  3909. Sub Stretch ()
  3910.  
  3911.     Dim x As Integer, y As Integer
  3912.     Static ShadowDC As Integer
  3913.     Static oldBM As Integer
  3914.  
  3915.   ' does a StretchBlt from a random box within the Original
  3916.   ' image and then displays it on the screen
  3917.  
  3918.   ' if first time then initialize
  3919.   If PlotInit = False Then
  3920.     
  3921.     'see if we need to reset changes made from previous init
  3922.     If PlotEnd = False Then
  3923.     
  3924.     'check if saver is permitted to run
  3925.     If CheckIfValidSaver(1) = 0 Then
  3926.       Exit Sub
  3927.     End If
  3928.     
  3929.     'see how many colors display can handle
  3930.     If TotalNumColors <= 256 Then 'see if palette based
  3931.       LogFile ("Saver does not work in palette display mode: " + Str$(PlotType)), 0
  3932.       NextSelection 'jump to next since this does not work
  3933.             'well with palettes
  3934.       Exit Sub
  3935.     End If
  3936.     
  3937.     ' set tick rate down
  3938.     Tick.Interval = 300
  3939.  
  3940.     ' start with original screen
  3941.     picture = original.Image
  3942.  
  3943.     ' start temp form same as original
  3944.     DC = original.hDC
  3945.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  3946.     'BitBlt Temp.hDC, 0, 0, ScaleWidth, ScaleHeight, hDC, 0, 0, &HCC0020
  3947.  
  3948.     'create hidden DC
  3949.     'ShadowDC = CreateCompatibleDC(hDC)
  3950.     'oldBM = SelectObject(ShadowDC, Original.Image)
  3951.  
  3952.     PlotInit = True
  3953.  
  3954.     'initial position is 1:1 copy
  3955.     x1 = 0
  3956.     y1 = 0
  3957.     x2 = ScaleWidth
  3958.     y2 = ScaleHeight
  3959.     
  3960.     'Calculate velocity limits
  3961.     MaxSpeedX = ScaleWidth * 15! / 800
  3962.     MaxSpeedY = ScaleWidth * 15! / 600
  3963.  
  3964.     ' zero initial velocity
  3965.     vx1 = MaxSpeedX * Rnd
  3966.     vy1 = MaxSpeedY * Rnd
  3967.     vx2 = -MaxSpeedX * Rnd
  3968.     vy2 = -MaxSpeedY * Rnd
  3969.  
  3970.     Pattern = &HCC0020 'Source Copy
  3971.   
  3972.   Else 'reset changes done by previous init
  3973.  
  3974.     ClearScreen
  3975.  
  3976.     'reset tick rate
  3977.     Tick.Interval = 50
  3978.  
  3979.     'destroy Device context
  3980.     'i = SelectObject(ShadowDC, oldBM)
  3981.     'i = DeleteDC(ShadowDC)
  3982.  
  3983.   End If
  3984.  
  3985.   Else  ' put run code here
  3986.  
  3987.     'make sure x1,y1 less than x2,y2 or swap
  3988.     If x1 > x2 Then x = x1: x1 = x2: x2 = x
  3989.     If y1 > y2 Then y = y1: y1 = y2: y2 = y
  3990.  
  3991.     'make sure that source box size does not
  3992.     'go below a minimum
  3993.     If x2 - x1 < 40 Then x2 = x1 + 40
  3994.     If y2 - y1 < 40 Then y2 = y1 + 40
  3995.  
  3996.     'Stretch Box from x1,y1 to x2,y2 onto display
  3997.  
  3998.     ' direct route does not work right:
  3999.     'DC = Original.hDC
  4000.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  4001.  
  4002.     'indirect route does not work on pallete display modes:
  4003.     DC = original.hDC
  4004.     x = x2 - x1: y = y2 - y1
  4005.     i = StretchBlt(temp.hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  4006.     ' now that it has been stretched, write to display
  4007.     DC = temp.hDC
  4008.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  4009.  
  4010.     'try this method:
  4011.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, ShadowDC, x1, y1, x, y, &HCC0020)
  4012.     
  4013.     'determine new acceleration
  4014.     ax1 = Rnd - .5
  4015.     ay1 = Rnd - .5
  4016.     ax2 = Rnd - .5
  4017.     ay2 = Rnd - .5
  4018.         
  4019.     'calculate new position
  4020.     x1 = x1 + vx1
  4021.     y1 = y1 + vy1
  4022.     x2 = x2 + vx2
  4023.     y2 = y2 + vy2
  4024.  
  4025.     'calculate new velocity
  4026.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  4027.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  4028.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  4029.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  4030.  
  4031.     'check if off screen
  4032.     If (x1 >= ScaleWidth) Then
  4033.         'change direction
  4034.         vx1 = -Abs(vx1)
  4035.         x1 = ScaleWidth - 1
  4036.     ElseIf (x1 < 0) Then
  4037.         'change direction
  4038.         vx1 = Abs(vx1)
  4039.         x1 = 0
  4040.     End If
  4041.  
  4042.     If (y1 >= ScaleHeight) Then
  4043.         'change direction
  4044.         vy1 = -Abs(vy1)
  4045.         y1 = ScaleHeight - 1
  4046.     ElseIf (y1 < 0) Then
  4047.         'change direction
  4048.         vy1 = Abs(vy1)
  4049.         y1 = 0
  4050.     End If
  4051.  
  4052.     'check if off screen
  4053.     If (x2 >= ScaleWidth) Then
  4054.         'change direction
  4055.         vx2 = -Abs(vx2)
  4056.         x2 = ScaleWidth - 1
  4057.     ElseIf (x2 < 0) Then
  4058.         'change direction
  4059.         vx2 = Abs(vx2)
  4060.         x2 = 0
  4061.     End If
  4062.  
  4063.     If (y2 >= ScaleHeight) Then
  4064.         'change direction
  4065.         vy2 = -Abs(vy2)
  4066.         y2 = ScaleHeight - 1
  4067.     ElseIf (y2 < 0) Then
  4068.         'change direction
  4069.         vy2 = Abs(vy2)
  4070.         y2 = 0
  4071.     End If
  4072.  
  4073.     
  4074.   End If
  4075.  
  4076. End Sub
  4077.  
  4078. Sub Tick_Timer ()
  4079.  
  4080.     ' check elapsed time to see if need to change type of plot
  4081.     ' also check if past midnight
  4082.     CurrentTime = Timer
  4083.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  4084.     MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  4085.  
  4086.     ZOrder 0' make sure form is still on top
  4087.  
  4088.     'clear old saver
  4089.     PlotInit = False: PlotEnd = True
  4090.     LogFile ("Cleanup of" + Str$(PlotType)), 1
  4091.     RunSelection 'just clean up after running
  4092.     'LogFile ("After Cleanup of " + Str$(PlotType)), 1
  4093.  
  4094.     'see if we want random selection
  4095.     NextSelection 'get new PlotType
  4096.  
  4097.     PlotInit = False: PlotEnd = False
  4098.  
  4099.     'remove password prompt
  4100.     PasswordLabel.Visible = False
  4101.  
  4102.     End If
  4103.     
  4104.     LastTime = CurrentTime
  4105.  
  4106.     RunSelection
  4107.  
  4108. End Sub
  4109.  
  4110.